var express = require('express')
var app = express()
app.get('/', function(req, res) {
res.render('index', { title: 'Express' })
})
app.listen(3000)
The below won't render the CSS (because it's not accessible as it's not served)
// Telling where to go look for views (using the set function)
app.set('view', __dirname + '/views') // place for the views
app.set('view engine', jade)
app.get('/', function(req, res) {
res.render('index', { title: 'Express' })
})
app.listen(3000)
You can serve the CSS via middleware You can use middleware like sessions report, logging (morgan), cookies, csrf, favicon, timeout, json
Serve static
serveStatic = require('serve-static')
logger = require('morgan'),
app.use(serveStatic(__dirname + '/public'))
// use a custom logger
app.use(function(req, res, next) {
console.log(req.method, req.url)
next()
})