diff --git a/routes/api.js b/routes/api.js index 2ab2eae..5ea0036 100644 --- a/routes/api.js +++ b/routes/api.js @@ -351,4 +351,30 @@ router.delete('/videos/:id', (req, res) => { }); }); +// Test Image +/** + * @swagger + * /smile: + * get: + * description: Use to request the smile image + * responses: + * 200: + * description: A successful response + * 404: + * description: Image not found + */ +router.get('/smile', (req, res) => { + res.setHeader('Access-Control-Allow-Origin', 'http://localhost:5500'); + res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE'); + res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); + const imagePath = path.join('/storage/smile.jpg'); + fs.access(imagePath, fs.constants.F_OK, (err) => { + if (err) { + console.error('Image not found:', err); + return res.status(404).json({ error: 'Image not found' }); + } + res.sendFile(imagePath); + }); +}); + module.exports = router;