Created
March 11, 2018 00:53
-
-
Save emersxw/35393fad72358dfe197e833a28579f34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'), | |
bodyParser = require('body-parser'); | |
app = express(); | |
const todoRoutes = require('./routes/todos'); | |
// body parser conf | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({extended: true})); | |
app.use(express.static(__dirname + '/views')); | |
app.use(express.static(__dirname + '/public')); | |
// Default route | |
app.get('/', (req, res) => { | |
// serving a static file | |
res.sendFile('index.html'); | |
}); | |
// Using /api/todos on every route in todoRoutes | |
app.use('/api/todos', todoRoutes); | |
const port = process.env.PORT || 5000; | |
app.listen(port, () => { | |
console.log(`App is running on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment