mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
minor changes as well as new post
This commit is contained in:
@@ -12,15 +12,20 @@ router.get('/', function(req, res, next) {
|
||||
var location = req.query.location;
|
||||
var key = req.query.key;
|
||||
|
||||
//implement a key for security
|
||||
//the esp8266 will send "nan" (not a number) if it has a faulty temperature read
|
||||
//we do not want to save it if it is not a number
|
||||
if(key == "esp1234" && temperature != "nan" && humidity != "nan"){
|
||||
|
||||
|
||||
//create a new object to insert into the database
|
||||
//using mongoose for object modeling
|
||||
var insert = new info({
|
||||
temperature: temperature,
|
||||
humidity: humidity,
|
||||
location: location
|
||||
});
|
||||
|
||||
//save information in the database
|
||||
insert.save(function (err) {
|
||||
if (err) return handleError(err);
|
||||
|
||||
@@ -28,6 +33,7 @@ router.get('/', function(req, res, next) {
|
||||
|
||||
console.log("--information saved--");
|
||||
|
||||
//send respnse back
|
||||
res.send("Information Logged");
|
||||
|
||||
}
|
||||
@@ -38,8 +44,6 @@ router.get('/', function(req, res, next) {
|
||||
res.send("Invalid Authentication");
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user