Make the UI pages HTML 4 compliant
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 12 Apr 2022 16:13:18 +0000 (18:13 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 12 Apr 2022 16:13:18 +0000 (18:13 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/ui/httpd/start.ts

index 28396dfcc9181a4ad0a8cbcf01ab6ce430ff1ba3..7ff8079a60a4e0001cf8d624dc179e13349cead0 100644 (file)
@@ -1,31 +1,45 @@
 import Bootstrap from '../../charging-station/Bootstrap';
 import express from 'express';
 
+const pageHeader = `
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+</head>`;
+const pageFooter = '</html>';
+
 const app = express();
 
 app.get('/', (request, response) => {
-  response.send(`
-
-  <form>
-    <input type="button" onclick="window.location.href='/start';" value="Start" />
-    <input type="button" onclick="window.location.href='/stop';" value="Stop" />
-  </form>
-
-  `);
+  response.send(
+    pageHeader +
+      `<body>
+       <form>
+         <input type="button" onclick="window.location.href='/start';" value="Start" />
+         <input type="button" onclick="window.location.href='/stop';" value="Stop" />
+       </form>
+       </body>` +
+      pageFooter
+  );
 });
 
 app.get('/start', (request, response, next) => {
   Bootstrap.getInstance().start().catch(next);
-  console.log('*** started');
-  response.send('<b>Started</b><br/><a href="/">Return to Top</a>');
+  console.info('*** started');
+  response.send(
+    pageHeader + '<body><b>Started</b><br/><a href="/">Return to Top</a></body>' + pageFooter
+  );
 });
 
 app.get('/stop', (request, response, next) => {
   Bootstrap.getInstance().stop().catch(next);
-  console.log('*** stopped');
-  response.send('<b>Stopped</b><br/><a href="/">Return to Top</a>');
+  console.info('*** stopped');
+  response.send(
+    pageHeader + '<body><b>Stopped</b><br/><a href="/">Return to Top</a></body>' + pageFooter
+  );
 });
 
 app.listen(process.env.PORT ?? 8080, () =>
-  console.log(`Listening on port: ${process.env.PORT ?? 8080}`)
+  console.info(`Listening on http://localhost:${process.env.PORT ?? 8080}`)
 );