Factor out OCPP message type to string method
[e-mobility-charging-stations-simulator.git] / src / ui / httpd / start.ts
CommitLineData
0a48f2b2 1import Bootstrap from '../../charging-station/Bootstrap';
175d4f46
JD
2import express from 'express';
3
69be24b4
JB
4const 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>`;
10const pageFooter = '</html>';
11
175d4f46
JD
12const app = express();
13
14app.get('/', (request, response) => {
69be24b4
JB
15 response.send(
16 pageHeader +
17 `<body>
18 <form>
19 <input type="button" onclick="window.location.href='/start';" value="Start" />
20 <input type="button" onclick="window.location.href='/stop';" value="Stop" />
21 </form>
22 </body>` +
23 pageFooter
24 );
175d4f46
JD
25});
26
27app.get('/start', (request, response, next) => {
28 Bootstrap.getInstance().start().catch(next);
69be24b4
JB
29 console.info('*** started');
30 response.send(
31 pageHeader + '<body><b>Started</b><br/><a href="/">Return to Top</a></body>' + pageFooter
32 );
175d4f46
JD
33});
34
35app.get('/stop', (request, response, next) => {
36 Bootstrap.getInstance().stop().catch(next);
69be24b4
JB
37 console.info('*** stopped');
38 response.send(
39 pageHeader + '<body><b>Stopped</b><br/><a href="/">Return to Top</a></body>' + pageFooter
40 );
175d4f46
JD
41});
42
43app.listen(process.env.PORT ?? 8080, () =>
69be24b4 44 console.info(`Listening on http://localhost:${process.env.PORT ?? 8080}`)
175d4f46 45);