Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
nodejs
index.js
index.js
//modules var util = require('util'); var http = require('http'); var fs = require('fs'); //vars var port = 8080; var fileName = "index.html"; //read file fs.readFile('index.html', 'UTF-8', function(err,data){ if (err) throw err; htmltext = data.toString(); }); //server http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(htmltext); //res.write('Hello World\n <br><b>at porta</b> '+port); res.end(); }).listen(port, '127.0.0.1'); //console console.log('Server running at http://127.0.0.1:'+port); util.puts('> hello world running on port '+port);
Reload page
Preview
W3C validation
Edit Code
JS Console