repl.it
@timmy_i_chen/

LameBrokenDemos

Express

No description

fork
loading
Files
  • index.js
  • public
  • routes
  • views
  • db.js
  • Packager files
  • package-lock.json
  • package.json
index.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
const express = require('express');
const bodyParser = require('body-parser');

const app =    express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));

app.use(require('./routes/guestbook'));

app.get('/api-docs', (req, res) => {
  res.sendFile(__dirname + '/views/api-index.html');
});

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/views/index.html');
});

const port = process.env.PORT || 8080;
app.listen(port, '0.0.0.0', () => {
  console.log(`Server started on port ${port}`);
});