[add] webapp on localhost:10501 (default)
This commit is contained in:
18
src/lib/webserver.ts
Normal file
18
src/lib/webserver.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as express from "express";
|
||||
import {Watcher} from "./types/state";
|
||||
import * as path from "path";
|
||||
import * as cors from "cors";
|
||||
|
||||
export function webappServe(watchers: Watcher[], host = 'localhost', port = 10501) {
|
||||
const webapp = express()
|
||||
|
||||
webapp.use(cors())
|
||||
|
||||
webapp.get('/status', (req, res) => {
|
||||
res.send(watchers)
|
||||
})
|
||||
|
||||
webapp.use('/', express.static(path.join(__dirname, '../../dist/')))
|
||||
|
||||
webapp.listen(port, host, () => console.log(`webserver listening at http://${host}:${port}`))
|
||||
}
|
||||
Reference in New Issue
Block a user