Compare commits

..

No commits in common. "977076711a172003da3c11feba7672ca30861ef2" and "acf0efd4b54968dde6a844bc87815b07ac65cb08" have entirely different histories.

View File

@ -5,14 +5,14 @@ const port = 80;
const http = require("http");
const fs = require('fs');
const SNAPSHOT_LIVING_ROOM_URL = "http://192.168.1.68/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06,"
const SNAPSHOT_SALON_URL = "http://192.168.1.68/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06,"
const SNAPSHOT_GARAGE_URL = "http://192.168.1.69/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=WX12cv06,"
function formatDate()
{
let date = new Date();
function snapshotPath(){
let date = new Date();
return date.getFullYear()
return "/snapshot/snapshot-"
+ date.getFullYear()
+ "-"
+ String(date.getMonth() + 1).padStart(2, '0')
+ "-"
@ -24,39 +24,26 @@ function formatDate()
+ "-"
+ String(date.getSeconds()).padStart(2, '0')
+ "_"
+ date.getMilliseconds();
}
function snapshotPath(room){
return "/snapshot/snapshot-"
+ room + "-"
+ formatDate()
+ date.getMilliseconds()
+".jpg";
}
function snapshotPathCamGarage(){
return snapshotPath("garage");
}
function snapshotPathCamLivingRoom(){
return snapshotPath("living_room");
}
function snapshotLivingRoom() {
http.get(SNAPSHOT_LIVING_ROOM_URL, (res) => {
res.pipe(fs.createWriteStream(snapshotPathCamLivingRoom()));
function snapshotSalon() {
http.get(SNAPSHOT_SALON_URL, (res) => {
res.pipe(fs.createWriteStream(snapshotPath()));
});
}
function snapshotGarage() {
http.get(SNAPSHOT_GARAGE_URL, (res) => {
res.pipe(fs.createWriteStream(snapshotPathCamGarage()));
res.pipe(fs.createWriteStream(snapshotPath()));
});
}
app.get('/snapshot', (req, res) => {
try{
snapshotLivingRoom();
snapshotSalon();
res.send('ok');
} catch(e)
{