-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (18 loc) · 761 Bytes
/
app.js
File metadata and controls
23 lines (18 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express'); // web framework
const fetch = require('node-fetch'); // for making AJAX requests
const path = require('path');
// put environmental variables defined in .env file on process.env
require('dotenv').config();
const app = express();
// serve files / assets from the dist folder
app.use(express.static('dist'));
// in response to `GET /` requests, send the file `dist/index.html`
app.get('/', (request, response) => {
response.sendFile(`${__dirname}/dist/index.html`);
});
// Heroku sets process.env.PORT in production; use 8000 in dev
const PORT = process.env.PORT || 8000;
// start up a server listening at PORT; on success, log a message
app.listen(PORT, () => {
console.log(`Listening at localhost:${PORT}`);
});