add 5 Ultimas Horas
This commit is contained in:
@@ -76,6 +76,26 @@ app.get('/api/history', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Recent Scans Endpoint (Last 5 Hours)
|
||||
app.get('/api/recent', async (req, res) => {
|
||||
try {
|
||||
const fiveHoursAgo = new Date(Date.now() - 5 * 60 * 60 * 1000);
|
||||
const logs = await prisma.accessLog.findMany({
|
||||
where: {
|
||||
timestamp: {
|
||||
gte: fiveHoursAgo
|
||||
}
|
||||
},
|
||||
orderBy: {
|
||||
timestamp: 'desc'
|
||||
}
|
||||
});
|
||||
res.json(logs);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Detection Endpoint (from Python)
|
||||
app.post('/api/detect', async (req, res) => {
|
||||
const { plate_number } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user