Stefan Brand
8f51247037
* GET all, PUT and POST working * JQuery Mobile page to show temperatures * Send HTML for index
33 lines
825 B
JavaScript
33 lines
825 B
JavaScript
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();
|
|
}
|
|
});
|
|
}
|