File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
1
var http = require ( "http" ) ;
2
2
3
3
http . createServer ( function ( req , res ) {
4
- var page = [ "<!doctype html>" ,
5
- "<html><head><title>Hello world</title></head>" ,
6
- "<body><h1>Hello, world!</h1></body></html>" ]
7
- html = page . join ( "" ) ;
4
+ var html = "<!doctype html>" +
5
+ "<html><head><title>Hello world</title></head>" +
6
+ "<body><h1>Hello, world!</h1></body></html>" ;
7
+
8
+ res . writeHead ( 200 , {
9
+ "Content-Type" : "text/html" ,
10
+ "Content-Length" : html . length
11
+ } ) ;
8
12
9
13
res . end ( html ) ;
10
14
} ) . listen ( 8000 ) ;
Original file line number Diff line number Diff line change @@ -20,15 +20,11 @@ http.createServer(function(req, res) {
20
20
} ) ;
21
21
}
22
22
23
- } ) . listen ( 8000 , "127.0.0.1" ) ;
23
+ } ) . listen ( 8000 ) ;
24
24
25
25
function getFile ( localPath , res ) {
26
26
fs . readFile ( localPath , function ( err , contents ) {
27
27
if ( ! err ) {
28
- res . writeHead ( 200 , {
29
- "Content-Type" : "text/html" ,
30
- "Content-Length" : contents . length
31
- } ) ;
32
28
res . end ( contents ) ;
33
29
} else {
34
30
res . writeHead ( 500 ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ http.createServer(function(req, res) {
28
28
} ) ;
29
29
}
30
30
31
- } ) . listen ( 8000 , "127.0.0.1" ) ;
31
+ } ) . listen ( 8000 ) ;
32
32
33
33
function getFile ( localPath , mimeType , res ) {
34
34
fs . readFile ( localPath , function ( err , contents ) {
Original file line number Diff line number Diff line change 1
- var http = require ( "http" ) ,
2
- connect = require ( "connect" ) ;
1
+ var connect = require ( "connect" ) ;
3
2
4
3
connect ( connect . static ( __dirname + "/public" ) ) . listen ( 8000 ) ;
You can’t perform that action at this time.
0 commit comments