var http = require('http'),
path = require('path'),
fs = require('fs'),
_base = '/home/sti2d/nodeJS/public';
http.createServer( function(req,res) {
pathname = _base + req.url;
console.log(pathname);
path.exists(pathname, function(exists) {
if (exists)
{
console.log("repertoire ok");
}
else {
res.writeHead(404);
res.write('bad request 404 \n');
res.end();
}
}
}).listen(8124);
console.log('server running');
Aucun commentaire:
Enregistrer un commentaire