Last active
August 29, 2015 14:13
-
-
Save PavelDemyanenko/6ec3a5d280cea2b9299e to your computer and use it in GitHub Desktop.
Simple web-server with url parsing.
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 url = require("url"); | |
function example(route, routes) { | |
function onRequest(req, res) { | |
var pathname = url.parse(req.url).pathname; | |
console.log("Request for " + pathname + " recieved."); | |
route(pathname, routes, res); | |
} | |
http.createServer(onRequest).listen(1337); | |
console.log("Server running at http://127.0.0.1:1337/"); | |
} | |
exports.example = example; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment