Вот тебе код, который сервит любые данные из директории public в корню директории с app.js файлом.
Поставь
nodejs и
npm, создай папку, затем
cd в эту папку и поставь express молуль:
npm install express
Затем создай app.js в этой папке с таким содержимым:
var http = require('http');
var express = require('express');
// catch exceptions and ignore them
// it is actually is a bad practice
process.on('uncaughtException', function(err) {
console.log(err);
});
var app = express();
// bind static folder
app.use(express.static(__dirname + '\public'));
// bind normal get /test request and response with test json
app.get('/test', function(req, res, next) {
res.json({ hello: 'world' });
});
// listen on port
var port = 10001;
app.listen(port, function() {
console.log('listening on port ' + port);
});
Запускается так: