Created
July 3, 2014 14:15
-
-
Save iamtchelo/9a70e0e996fe09fcca34 to your computer and use it in GitHub Desktop.
Create a simple server with express.js
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'); | |
var app = express(); | |
var port = process.env.PORT || 8080; | |
// routes | |
app.get('/test', function(request, response) { | |
response.send('Test router!'); | |
}); | |
// router with params | |
app.get('/hello/:name', function(request, response) { | |
name = request.params.name; | |
response.send('Hello ' + name); | |
}); | |
app.listen(port); | |
console.log('Magic happens on port ' + port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment