Use Express router for caption endpoint
This commit is contained in:
parent
414c9bd5fb
commit
d2e1577acb
|
@ -3621,7 +3621,7 @@ require('./src/endpoints/translate').registerEndpoints(app, jsonParser);
|
|||
require('./src/endpoints/classify').registerEndpoints(app, jsonParser);
|
||||
|
||||
// Image captioning
|
||||
require('./src/endpoints/caption').registerEndpoints(app, jsonParser);
|
||||
app.use('/api/extra/caption', require('./src/endpoints/caption').router);
|
||||
|
||||
// Web search extension
|
||||
require('./src/endpoints/serpapi').registerEndpoints(app, jsonParser);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const express = require('express');
|
||||
const { jsonParser } = require('../express-common');
|
||||
|
||||
const TASK = 'image-to-text';
|
||||
|
||||
/**
|
||||
* @param {import("express").Express} app
|
||||
* @param {any} jsonParser
|
||||
*/
|
||||
function registerEndpoints(app, jsonParser) {
|
||||
app.post('/api/extra/caption', jsonParser, async (req, res) => {
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/', jsonParser, async (req, res) => {
|
||||
try {
|
||||
const { image } = req.body;
|
||||
|
||||
|
@ -28,8 +28,5 @@ function registerEndpoints(app, jsonParser) {
|
|||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
registerEndpoints,
|
||||
};
|
||||
module.exports = { router };
|
||||
|
|
Loading…
Reference in New Issue