File size: 1,212 Bytes
abe15dd
039db5e
abe15dd
 
 
1b3ef2b
179bd1d
039db5e
1bfd55a
039db5e
 
 
d80334f
abe15dd
039db5e
 
7ee3240
039db5e
7ee3240
7dd735c
7ee3240
039db5e
7dd735c
039db5e
abe15dd
7dd735c
7ee3240
039db5e
d80334f
abe15dd
 
5c58195
 
 
 
 
 
 
f3bf338
7dd735c
4447358
039db5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask, request, jsonify, Response,redirect
from flask_cors import CORS
import time
import random
from text2generation import generate_long_answer  # Your own function

app = Flask(__name__)
CORS(app)

@app.route('/health')
def health_check():
    return jsonify({"status": "ready"}), 200

# Standard answer route
@app.route('/ask', methods=['POST'])
def ask_question():
    try:
        data = request.get_json()
        question = data.get('question', '').strip()

        if not question:
            return jsonify({"error": "Question is required"}), 400

        answer = generate_long_answer(question)
        return jsonify({"question": question, "answer": answer})

    except Exception as e:
        return jsonify({"error": str(e)}), 500

@app.route('/get_video')
def get_video():
    video_lst=[
        "https://videos.pexels.com/video-files/3571264/3571264-sd_640_360_30fps.mp4",
        "https://videos.pexels.com/video-files/3052446/3052446-hd_1920_1080_30fps.mp4",
        "https://videos.pexels.com/video-files/6394054/6394054-sd_960_480_24fps.mp4",
        
    ]
    return redirect(random.choice(video_lst))


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860)