-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
36 lines (29 loc) · 807 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
Module dependencies.
@module app
*/
const express = require('express');
const cors = require('cors');
const app = express();
const path = require('path');
require('dotenv').config();
const port = process.env.PORT || 9000;
app.use(cors());
// Serve static files from the public folder
app.use(express.static('public'));
/**
GET /
@function
@memberof module:app
@param {Object} req - Express request object.
@param {Object} res - Express response object.
@param {function} next - Express middleware next function.
@returns {Object} - HTML file.
*/
app.get('/', (req, res, next) => {
res.sendFile(path.join(__dirname + '/index.html'));
})
// Start listening on the specified port
app.listen(port, () => {
console.log(`Web server listening on port ${port}`)
})