Spaces:
Running
Running
| from flask import Flask, request, jsonify | |
| app = Flask(__name__) | |
| def home(): | |
| return jsonify({ | |
| "status": "Higgsfield API Ready", | |
| "endpoints": ["/generate", "/status"], | |
| "model": "diffusers (free)" | |
| }) | |
| def generate(): | |
| prompt = request.json.get('prompt', 'cinematic video') | |
| try: | |
| # Use Stable Diffusion + AnimateDiff (free, no API key) | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| "runwayml/stable-diffusion-v1-5", | |
| torch_dtype=torch.float32 | |
| ) | |
| image = pipe(prompt).images[0] | |
| image.save("/app/output.png") | |
| return jsonify({ | |
| "success": True, | |
| "message": "Image generated (video needs GPU)", | |
| "prompt": prompt | |
| }) | |
| except Exception as e: | |
| return jsonify({ | |
| "success": False, | |
| "error": str(e), | |
| "message": "Free CPU can generate images. Video needs GPU." | |
| }) | |
| def status(): | |
| return jsonify({"status": "online", "type": "image-generation"}) | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) |