refactor 3-more into separate books

This commit is contained in:
Ilya Kantor 2015-02-27 13:21:58 +03:00
parent bd1d5e4305
commit 87639b2740
423 changed files with 9 additions and 9 deletions

View file

@ -0,0 +1,38 @@
var http = require('http');
var url = require('url');
var static = require('node-static');
var file = new static.Server('.', { cache: 0 });
function accept(req, res) {
var urlParsed = url.parse(req.url, true);
if (urlParsed.pathname == '/user') {
var id = urlParsed.query.id;
var callback = urlParsed.query.callback;
res.setHeader('Content-Type', 'application/javascript; charset=utf-8');
var user = {
name: "Вася",
id: id
};
res.end(callback + '(' + JSON.stringify(user) + ')');
} else {
file.serve(req, res);
}
}
// ------ запустить сервер -------
if (!module.parent) {
http.createServer(accept).listen(8080);
} else {
exports.accept = accept;
}