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