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