Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[misc] Updating Readme

  • Loading branch information...
commit ba8fd91369831c356d87e64726de131306991acc 1 parent 5d1e020
@Marak authored
Showing with 43 additions and 19 deletions.
  1. +36 −2 ReadMe.md
  2. +4 −10 package.json
  3. +3 −7 server.js
View
38 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
View
14 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"
+}
View
10 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);
Please sign in to comment.
Something went wrong with that request. Please try again.