Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,30 +16,31 @@ def generate_content():
|
|
| 16 |
try:
|
| 17 |
data = request.get_json()
|
| 18 |
question = data.get('question', '').strip()
|
| 19 |
-
|
| 20 |
if not question:
|
| 21 |
return jsonify({"error": "Question is required"}), 400
|
| 22 |
-
|
| 23 |
-
# Generate
|
| 24 |
content = generate_educational_content(question)
|
| 25 |
if "error" in content:
|
| 26 |
return jsonify(content), 500
|
| 27 |
-
|
| 28 |
-
#
|
| 29 |
video_url = create_video(
|
| 30 |
content['video_script'],
|
| 31 |
content['audio_script'],
|
| 32 |
content['summary']
|
| 33 |
)
|
| 34 |
-
|
| 35 |
return jsonify({
|
| 36 |
"summary": content['summary'],
|
| 37 |
"video_url": video_url,
|
| 38 |
"status": "success"
|
| 39 |
})
|
| 40 |
-
|
| 41 |
except Exception as e:
|
| 42 |
return jsonify({"error": str(e)}), 500
|
| 43 |
|
| 44 |
if __name__ == '__main__':
|
|
|
|
| 45 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 16 |
try:
|
| 17 |
data = request.get_json()
|
| 18 |
question = data.get('question', '').strip()
|
| 19 |
+
|
| 20 |
if not question:
|
| 21 |
return jsonify({"error": "Question is required"}), 400
|
| 22 |
+
|
| 23 |
+
# Generate video script, audio script, and summary
|
| 24 |
content = generate_educational_content(question)
|
| 25 |
if "error" in content:
|
| 26 |
return jsonify(content), 500
|
| 27 |
+
|
| 28 |
+
# Generate video using content
|
| 29 |
video_url = create_video(
|
| 30 |
content['video_script'],
|
| 31 |
content['audio_script'],
|
| 32 |
content['summary']
|
| 33 |
)
|
| 34 |
+
|
| 35 |
return jsonify({
|
| 36 |
"summary": content['summary'],
|
| 37 |
"video_url": video_url,
|
| 38 |
"status": "success"
|
| 39 |
})
|
| 40 |
+
|
| 41 |
except Exception as e:
|
| 42 |
return jsonify({"error": str(e)}), 500
|
| 43 |
|
| 44 |
if __name__ == '__main__':
|
| 45 |
+
# Run on port 7860 (or use os.getenv('PORT', 7860) for cloud deployment)
|
| 46 |
app.run(host='0.0.0.0', port=7860)
|