Update server.js
Browse files
server.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
import dotenv from 'dotenv';
|
5 |
|
|
|
6 |
dotenv.config();
|
7 |
|
8 |
const app = express();
|
@@ -19,6 +19,9 @@ app.post('/generate-image', async (req, res) => {
|
|
19 |
}
|
20 |
|
21 |
try {
|
|
|
|
|
|
|
22 |
const response = await fetch('https://api-inference.huggingface.co/models/your-model-name', {
|
23 |
method: 'POST',
|
24 |
headers: {
|
|
|
1 |
+
const express = require('express');
|
2 |
+
const bodyParser = require('body-parser');
|
3 |
+
const dotenv = require('dotenv');
|
|
|
4 |
|
5 |
+
// Загрузка переменных окружения из .env файла
|
6 |
dotenv.config();
|
7 |
|
8 |
const app = express();
|
|
|
19 |
}
|
20 |
|
21 |
try {
|
22 |
+
// Динамический импорт node-fetch
|
23 |
+
const fetch = (await import('node-fetch')).default;
|
24 |
+
|
25 |
const response = await fetch('https://api-inference.huggingface.co/models/your-model-name', {
|
26 |
method: 'POST',
|
27 |
headers: {
|