Commit | Line | Data |
---|---|---|
175d4f46 JD |
1 | import express from 'express'; |
2 | ||
8114d10e JB |
3 | import Bootstrap from '../../charging-station/Bootstrap'; |
4 | ||
69be24b4 JB |
5 | const pageHeader = ` |
6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
7 | "http://www.w3.org/TR/html4/strict.dtd"> | |
8 | <html> | |
9 | <head> | |
10 | </head>`; | |
11 | const pageFooter = '</html>'; | |
12 | ||
175d4f46 | 13 | const app = express(); |
7cc0b033 | 14 | app.disable('x-powered-by'); |
175d4f46 JD |
15 | |
16 | app.get('/', (request, response) => { | |
69be24b4 JB |
17 | response.send( |
18 | pageHeader + | |
19 | `<body> | |
20 | <form> | |
21 | <input type="button" onclick="window.location.href='/start';" value="Start" /> | |
22 | <input type="button" onclick="window.location.href='/stop';" value="Stop" /> | |
23 | </form> | |
24 | </body>` + | |
25 | pageFooter | |
26 | ); | |
175d4f46 JD |
27 | }); |
28 | ||
29 | app.get('/start', (request, response, next) => { | |
30 | Bootstrap.getInstance().start().catch(next); | |
69be24b4 JB |
31 | console.info('*** started'); |
32 | response.send( | |
33 | pageHeader + '<body><b>Started</b><br/><a href="/">Return to Top</a></body>' + pageFooter | |
34 | ); | |
175d4f46 JD |
35 | }); |
36 | ||
37 | app.get('/stop', (request, response, next) => { | |
38 | Bootstrap.getInstance().stop().catch(next); | |
69be24b4 JB |
39 | console.info('*** stopped'); |
40 | response.send( | |
41 | pageHeader + '<body><b>Stopped</b><br/><a href="/">Return to Top</a></body>' + pageFooter | |
42 | ); | |
175d4f46 JD |
43 | }); |
44 | ||
45 | app.listen(process.env.PORT ?? 8080, () => | |
69be24b4 | 46 | console.info(`Listening on http://localhost:${process.env.PORT ?? 8080}`) |
175d4f46 | 47 | ); |