This commit is contained in:
Ibnu Naz'm Ar-rosyid
2025-07-18 20:05:17 +07:00
commit bea44c1b7c
234 changed files with 5681 additions and 0 deletions

View 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;