forked from vedeeva/SaveAir
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (20 loc) · 727 Bytes
/
server.js
File metadata and controls
24 lines (20 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const app = express();
const server = http.createServer(app);
const fetch = require('node-fetch');
require ('dotenv').config();
// Needed to process body parameters for POST requests
app.use(bodyParser.urlencoded({ extended: true }));
// Needed to use External Stylesheet with NodeJS and Express
app.use(express.static(__dirname + '/public'));
// Default endpoint
app.get('/', (req, res) => {
res.sendFile(__dirname + "/index.html");
});
// Server will always find an open port.
const port = process.env.PORT || 3001;
server.listen(port, '0.0.0.0', () => {
console.log(`Server listening on port ${port}`);
});