var http = require('http');
var fs = require('fs');
var server = http.createServer();
server.on('request', doRequest);
server.listen(1337);
function doRequest(req, res) {
fs.readFile('./index.html', 'UTF-8', doRead);
function doRead(err, data) {
res.setHeader('Content-Type', 'text/html');
res.write(data);
res.end();
}
}
console.log('Server running at http://127.0.0.1:1337/');
<html>
<head>
<meta charset="utf-8">
<title> Insert title here</title>
</meta>
<body>
<h1>Index Page</h1>
<pthis is sample page.</p>
<p>これはサンプルで作ったページです</p>
</body>
</head>
</html>