Skip to content

Commit

Permalink
[misc] Updating Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Apr 17, 2011
1 parent 5d1e020 commit ba8fd91
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
38 changes: 36 additions & 2 deletions ReadMe.md
@@ -1,3 +1,37 @@
# nothing really here
# hellonode!
the simplest possible http server hello world example in node

## this is a demo node.js application that starts up an http server. useful to have when you need to stub out tests for spawning http servers from git urls and npm packages :-)
## features

- Example package.json
- Starts up simple httpServer with helloworld

## installation

git clone git://github.com/Marak/hellonode.git
cd hellonode
node server.js

Now you should have a listening node.js http server running on port 80

## the code

// requires node's http module
var http = require('http');

// creates a new httpServer instance
http.createServer(function (req, res) {
// ^^ this is the callback, or request handler for the httpServer
// respond to the browser, write some headers so the
// browser knows what type of content we are sending
res.writeHead(200, {'Content-Type': 'text/plain'});
// write some content to the browser that your user will see
res.write('hello, i know nodejitsu.')
// close the response
res.end();
}).listen(80); // the server will listen on port 80
14 changes: 4 additions & 10 deletions package.json
@@ -1,14 +1,8 @@
{
"name": "hellonode",
"description": "demo node.js application that starts up an http server",
"version": "0.1.0",
"author": "Marak Squires",
"repository": {
"type": "git",
"url": "http://github.com/Marak/hellonode.git"
},
"subdomain": "hellonode",
"scripts": {
"start":"server.js"
"start": "server.js"
},
"engine": [ "node >=0.1.90" ]
}
"version": "0.0.0"
}
10 changes: 3 additions & 7 deletions server.js
@@ -1,11 +1,7 @@
var sys = require('sys'),
http = require('http');
var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello, i know nodejitsu! write more stuff')
res.write('hello, i know nodejitsu.')
res.end();
}).listen(80);

/* server started */
sys.puts('> hello world running on port 80');
}).listen(80);

0 comments on commit ba8fd91

Please sign in to comment.