Created
March 17, 2016 13:48
-
-
Save AndyNovo/3f98954700a412536dd1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 http = require("http"); | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.use(bodyParser.json()); | |
aRouter.use(bodyParser.urlencoded({ extended: true })); | |
aRouter.use(express.static(__dirname + "/client")); | |
aRouter.get('/users/:userid', function(req, res){ | |
res.send("You asked for data from User "+req.params.userid); | |
}); | |
aRouter.post('/users', function(req, res){ | |
res.json(req.body); | |
}); | |
aRouter.get("/*", function(req, res){ | |
res.send("Not found"); | |
}); | |
myServer.listen(8080, '0.0.0.0'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment