source: other-projects/bib-stinky/trunk/nodejs-server/express-web-server.js@ 36315

Last change on this file since 36315 was 36315, checked in by davidb, 21 months ago

Utility scripts for starting and stopping the Express-based web server that will ultimately provideBib-Stinky functionality; imprinted of files developed for the Hey You Interact with Me project

File size: 694 bytes
Line 
1// Setup Express
2const path = require('path')
3const express = require("express");
4const cors = require("cors");
5
6const app = express();
7
8const port = process.env.PORT || 3000;
9const public_dir = path.join(__dirname, 'public')
10
11
12app.use(cors());
13app.use('/', express.static(public_dir))
14
15//// To help with POST and PUT requests to the server
16//app.use(express.json());
17//app.use(express.urlencoded({ extended: true }));
18
19
20app.get("/", (req, res) => {
21 //res.send('Hello World!')
22 //res.json({ message: "Test JSON message" });
23 res.redirect("/index.html");
24});
25
26
27app.listen(port, () => {
28 console.log(`Started CORS-enabled Express web server running on port ${port}.`);
29});
Note: See TracBrowser for help on using the repository browser.