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
|
---|
2 | const path = require('path')
|
---|
3 | const express = require("express");
|
---|
4 | const cors = require("cors");
|
---|
5 |
|
---|
6 | const app = express();
|
---|
7 |
|
---|
8 | const port = process.env.PORT || 3000;
|
---|
9 | const public_dir = path.join(__dirname, 'public')
|
---|
10 |
|
---|
11 |
|
---|
12 | app.use(cors());
|
---|
13 | app.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 |
|
---|
20 | app.get("/", (req, res) => {
|
---|
21 | //res.send('Hello World!')
|
---|
22 | //res.json({ message: "Test JSON message" });
|
---|
23 | res.redirect("/index.html");
|
---|
24 | });
|
---|
25 |
|
---|
26 |
|
---|
27 | app.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.