Created
December 21, 2015 09:45
-
-
Save dj2bee/68dba526ba810428b84a to your computer and use it in GitHub Desktop.
NodeJs Express Webserver
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
var express = require('express'), | |
bodyParser = require('body-parser'), | |
http = require('http'), | |
app = express(), | |
router = express.Router(), | |
apiUrl = '/api', | |
port = 80; | |
// Setup bodyParser | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(bodyParser.json()); | |
// Set routes | |
app.use(express.static('./public')); | |
app.use(apiUrl, router); | |
var httpServer = http.createServer(app); | |
httpServer.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment