[add] webapp on localhost:10501 (default)

This commit is contained in:
2020-05-03 15:26:16 +02:00
parent 1577230a12
commit 24d9d6578a
15 changed files with 4066 additions and 53 deletions

18
src/lib/webserver.ts Normal file
View 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}`))
}