sreepathi-ravikumar commited on
Commit
0f1e571
·
verified ·
1 Parent(s): 33ce818

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from flask_cors import CORS
3
+ from text2generation import generate_educational_content
4
+ from video_processor import create_video
5
+ import os
6
+
7
+ app = Flask(_name_)
8
+ CORS(app)
9
+
10
+ @app.route('/health')
11
+ def health_check():
12
+ return jsonify({"status": "ready"}), 200
13
+
14
+ @app.route('/generate', methods=['POST'])
15
+ 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 all content types
24
+ content = generate_educational_content(question)
25
+ if "error" in content:
26
+ return jsonify(content), 500
27
+
28
+ # Create video (async would be better for production)
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)