TempTracker/routes/index.js

34 lines
825 B
JavaScript
Raw Normal View History

var fs = require("fs");
exports.index = function(req, res) {
var id = fs.readFile("./html/index.html", function(err, data) {
if (err == null) {
res.type("text/html");
res.status(200).send(data);
} else {
res.type("text/html");
res.status(404).send("<html><head><title>404</title><body><h1>404</h1><p>Page not found</p></body></html>");
}
});
}
exports.inc = function(req, res) {
var options = { root: global.rootpath + "/html/inc/" };
res.sendFile(req.params.file, options, function(err) {
if (err) {
console.log(err);
res.status(err.status).end();
}
});
}
exports.img = function(req, res) {
var options = { root: global.rootpath + "/html/inc/images" };
res.sendFile(req.params.file, options, function(err) {
if (err) {
console.log(err);
res.status(err.status).end();
}
});
}