Created
March 5, 2016 11:41
-
-
Save oldaccountarchived/52ee8dcb8ab96eb9f32b 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
'use strict'; | |
let express = require('express'), | |
bodyParser = require('bodyParser'), | |
path = require('path'), | |
morgan = require('morgan'), | |
app = express(), | |
hostname = '127.0.0.1', | |
port = 8080, | |
publicDir = '/public'; | |
app.use(morgan('dev')); | |
app.use(bodyParser.json()); | |
app.use(express.static(publicDir)); | |
app.listen(port, hostname); | |
app.get("/", function (req, res) { | |
res.sendFile(path.join(publicDir, '/index.html')); | |
}); | |
app.get("hello/:name", function (req, res) { | |
res.send('Hey ' + req.params.user + '!'); | |
}); | |
console.log('Static file server showing %s listening at http://%s:%s', publicDir, hostname, port); | |
app.listen(port, hostname); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment