00Boobs00 commited on
Commit
148c64e
·
verified ·
1 Parent(s): 91d8020

Upload pages/api/comfy.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/api/comfy.js +34 -0
pages/api/comfy.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
9
+ // NOTE: Replace with your actual ComfyUI endpoint
10
+ const COMFYUI_URL = process.env.COMFYUI_URL || 'http://localhost:8188';
11
+
12
+ try {
13
+ // This is a simplified mock logic for the proxy structure.
14
+ // In a real scenario, you would send a workflow object to ComfyUI.
15
+ // Example:
16
+ // const response = await fetch(`${COMFYUI_URL}/prompt`, {
17
+ // method: 'POST',
18
+ // headers: { 'Content-Type': 'application/json' },
19
+ // body: JSON.stringify({ prompt: prompt }),
20
+ // });
21
+
22
+ // Simulating a delay
23
+ await new Promise(resolve => setTimeout(resolve, 1500));
24
+
25
+ // Mock response
26
+ return res.status(200).json({
27
+ url: 'https://picsum.photos/seed/' + encodeURIComponent(prompt) + '/800/450'
28
+ });
29
+
30
+ } catch (error) {
31
+ console.error('ComfyUI Error:', error);
32
+ return res.status(500).json({ message: 'Internal Server Error' });
33
+ }
34
+ }