File size: 546 Bytes
83b4013 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import express from "express";
const app = express();
const responses = {
"dog": "images/dog.jpg",
"cat": "images/cat.jpg",
"car": "images/car.jpg",
};
app.use(express.json());
app.post("/generate-image", (req, res) => {
let { model } = req.body;
if (!model) {
return res.status(400).json({ error: "No model provided" });
}
if (!responses[model]) {
return res.status(400).json({ error: "Invalid model" });
}
res.json({ imagePath: responses[model] });
});
app.listen(3000, () => {
console.log("API started on port 3000");
}); |