update api.js
This commit is contained in:
@@ -3,6 +3,8 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const db = require('../db'); // Assurez-vous d'importer le fichier db.js
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
@@ -288,4 +290,26 @@ router.post('/delete', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* @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) => {
|
||||
const imagePath = path.join(__dirname, '../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;
|
||||
|
||||
Reference in New Issue
Block a user