Update server.js
Browse files
server.js
CHANGED
|
@@ -11,7 +11,16 @@ const apiKey = process.env.KEY;
|
|
| 11 |
|
| 12 |
app.use(bodyParser.json());
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
const { prompt } = req.body;
|
| 16 |
|
| 17 |
if (!prompt) {
|
|
|
|
| 11 |
|
| 12 |
app.use(bodyParser.json());
|
| 13 |
|
| 14 |
+
// Обработка только POST запросов
|
| 15 |
+
app.all('*', (req, res, next) => {
|
| 16 |
+
if (req.method !== 'POST') {
|
| 17 |
+
res.status(405).send('Только POST');
|
| 18 |
+
} else {
|
| 19 |
+
next();
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
app.post('/generate-image', async (req, res) => {
|
| 24 |
const { prompt } = req.body;
|
| 25 |
|
| 26 |
if (!prompt) {
|