00Boobs00 commited on
Commit
ebb7bd3
·
verified ·
1 Parent(s): 3c845f4

Upload pages/api/comfy.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/api/comfy.js +24 -0
pages/api/comfy.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // API Proxy for ComfyUI
2
+ export default async function handler(req, res) {
3
+ if (req.method !== 'POST') {
4
+ return res.status(405).json({ message: 'Method not allowed' });
5
+ }
6
+
7
+ const { prompt } = req.body;
8
+ const COMFYUI_URL = process.env.COMFYUI_URL || 'http://localhost:8188';
9
+
10
+ try {
11
+ // Simulate processing time
12
+ await new Promise(resolve => setTimeout(resolve, 2000));
13
+
14
+ // Return a deterministic image based on prompt for consistency
15
+ const seed = encodeURIComponent(prompt.replace(/\s/g, ''));
16
+ return res.status(200).json({
17
+ url: `https://picsum.photos/seed/${seed}/800/450`
18
+ });
19
+
20
+ } catch (error) {
21
+ console.error('ComfyUI Error:', error);
22
+ return res.status(500).json({ message: 'Internal Server Error' });
23
+ }
24
+ }