Initial commit

This commit is contained in:
2024-05-25 21:36:14 +05:00
parent 464057700d
commit d20288cada
17 changed files with 37 additions and 13 deletions

25
index.js Normal file → Executable file
View File

@ -37,10 +37,13 @@ setInterval(function() {
let comment = "";
fs.readFile('./pills.json', 'utf8', (err, data) => {
let jdata = JSON.parse(data);
console.log(jdata);
let num = j_max(jdata) + 1;
let name = `pill_${num}`;
let c_date = get_date(last);
jwrite_pill(name, pill, c_date, comment);
if(Object.values(jdata).at(-1)["date"] != c_date){
jwrite_pill(name, pill, c_date, comment);
}
})
console.log(pill);
today = timeu;
@ -77,6 +80,26 @@ app.get('/', (req, res) => {
res.redirect("/user");
})
app.post('/nfc', (req, res) => {
console.log("nfc");
res.send("good");
let inpraw = JSON.stringify(req.body);
let inp = JSON.parse(inpraw);
let pill = `[${inp["pill"]}]`;
let comment = "";
fs.readFile('./pills.json', 'utf8', (err, data) => {
let jdata = JSON.parse(data);
let num = j_max(jdata) + 1;
let name = `pill_${num}`;
let c_date = get_date(today);
console.log("nfc good");
console.log(name, pill, c_date, comment);
jwrite_pill(name, pill, c_date, comment);
})
// console.log(js);
})
console.log(get_date(today));
function dict_reverse(obj) {