Spaces:
Sleeping
Sleeping
| from flask import Flask, request, jsonify | |
| from flask_cors import CORS | |
| from text2generation import generate_educational_content | |
| from video_processor import create_video | |
| import os | |
| app = Flask(_name_) | |
| CORS(app) | |
| def health_check(): | |
| return jsonify({"status": "ready"}), 200 | |
| def generate_content(): | |
| try: | |
| data = request.get_json() | |
| question = data.get('question', '').strip() | |
| if not question: | |
| return jsonify({"error": "Question is required"}), 400 | |
| # Generate all content types | |
| content = generate_educational_content(question) | |
| if "error" in content: | |
| return jsonify(content), 500 | |
| # Create video (async would be better for production) | |
| video_url = create_video( | |
| content['video_script'], | |
| content['audio_script'], | |
| content['summary'] | |
| ) | |
| return jsonify({ | |
| "summary": content['summary'], | |
| "video_url": video_url, | |
| "status": "success" | |
| }) | |
| except Exception as e: | |
| return jsonify({"error": str(e)}), 500 | |
| if _name_ == '_main_': | |
| app.run(host='0.0.0.0', port=7860) |