Created
February 18, 2017 23:14
-
-
Save kiknaio/f73a0696c11f7ca58fd6cc7111389a07 to your computer and use it in GitHub Desktop.
How to make guestbook with Express.js (part 1)
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'); | |
const morgan = require('morgan'); | |
const bodyParser = require('body-parser'); | |
// Define port for the server | |
const PORT = 3000; | |
const app = express(); | |
// Require routes | |
const routes = require('./routes/routes'); | |
// Set Application views directory | |
app.set('view', __dirname + 'views'); | |
// Set Application view engine | |
app.set('view engine', 'ejs'); | |
// Use body-parser to parse incoming requests and get body of it | |
app.use(bodyParser.urlencoded({ extended: false })); | |
// Log every activity on the server | |
app.use(morgan('dev')); | |
// Use required routes | |
app.use('/', routes); | |
// Start server and listen to port 3000 | |
app.listen(PORT, () => { | |
console.log(`Application is running on ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment