Skip to content

Instantly share code, notes, and snippets.

@lucassmagal
Created May 13, 2013 14:00
Show Gist options
  • Save lucassmagal/5568507 to your computer and use it in GitHub Desktop.
Save lucassmagal/5568507 to your computer and use it in GitHub Desktop.
express.js hello world

Hello World!

var express = require('express');
var app = express();
app.get('/hello', function(req, res){
var body = 'Hello World';
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Length', body.length);
res.end(body);
});
app.get('/hello-simple', function(req, res){
res.send('Hello World SIMPLE');
});
app.listen(3000);
console.log('Listening on port 3000');
{
"name": "hello-world",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment