done
This commit is contained in:
13
Server/routes/checkRoute.js
Normal file
13
Server/routes/checkRoute.js
Normal file
@ -0,0 +1,13 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
router.get('/check', (req, res) => {
|
||||
res.status(200).json({
|
||||
status: 'ok',
|
||||
message: 'Server is up and running',
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
31
Server/routes/classificationRoute.js
Normal file
31
Server/routes/classificationRoute.js
Normal file
@ -0,0 +1,31 @@
|
||||
const express = require('express');
|
||||
const multer = require('multer');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { classifyImage } = require('../controllers/classificationController');
|
||||
|
||||
const router = express.Router();
|
||||
const upload = multer({ dest: 'uploads/' });
|
||||
|
||||
router.post('/classify', upload.single('image'), async (req, res) => {
|
||||
try {
|
||||
if (!req.file) {
|
||||
return res.status(400).json({ error: 'No image file uploaded' });
|
||||
}
|
||||
|
||||
const imagePath = path.join(__dirname, `../${req.file.path}`);
|
||||
const predictedClass = await classifyImage(imagePath);
|
||||
|
||||
fs.unlinkSync(imagePath);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
predictedClass,
|
||||
});
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
Reference in New Issue
Block a user