Skip to content

Instantly share code, notes, and snippets.

@oldaccountarchived
Created March 5, 2016 11:41
Show Gist options
  • Save oldaccountarchived/52ee8dcb8ab96eb9f32b to your computer and use it in GitHub Desktop.
Save oldaccountarchived/52ee8dcb8ab96eb9f32b to your computer and use it in GitHub Desktop.
'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