Created
February 27, 2012 14:39
-
-
Save brenoferreira/1924265 to your computer and use it in GitHub Desktop.
Hello World in HTML with NodeJS
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <body> | |
| <p>Hello world! Node is awesome, is it not?</p> | |
| </body> | |
| </html> |
This file contains hidden or 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 http = require('http'); | |
| var fileSystem = require('fs'); | |
| var server = http.createServer(function(req, resp){ | |
| fileSystem.readFile('./index.html', function(error, fileContent){ | |
| if(error){ | |
| resp.writeHead(500, {'Content-Type': 'text/plain'}); | |
| resp.end('Error'); | |
| } | |
| else{ | |
| resp.writeHead(200, {'Content-Type': 'text/html'}); | |
| resp.write(fileContent); | |
| resp.end(); | |
| } | |
| }); | |
| }); | |
| server.listen(8080); | |
| console.log('Listening at: localhost:8080'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any embedded version, like
echoin php?