Spaces:
Runtime error
Runtime error
| const express = require('express'); | |
| const axios = require('axios'); | |
| const app = express(); | |
| const port = process.env.PORT || 3000; | |
| app.use(express.json()); | |
| app.post('/generate-image', async (req, res) => { | |
| const { modelId, prompt } = req.body; | |
| try { | |
| const response = await axios.post('https://api.civitai.com/generate', { | |
| modelId: modelId, | |
| prompt: prompt | |
| }, { | |
| headers: { | |
| 'Authorization': `Bearer ${process.env.CIVITAI_API_KEY}` | |
| } | |
| }); | |
| res.json(response.data); | |
| } catch (error) { | |
| res.status(500).send(error.message); | |
| } | |
| }); | |
| app.listen(port, () => { | |
| console.log(`Civitai Generator listening at http://localhost:${port}`); | |
| }); | |