Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from text2generation import generate_long_answer # Your own function
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
CORS(app)
|
| 8 |
-
|
| 9 |
@app.route('/health')
|
| 10 |
def health_check():
|
| 11 |
return jsonify({"status": "ready"}), 200
|
|
@@ -14,6 +14,7 @@ def health_check():
|
|
| 14 |
@app.route('/ask', methods=['POST'])
|
| 15 |
def ask_question():
|
| 16 |
try:
|
|
|
|
| 17 |
data = request.get_json()
|
| 18 |
question = data.get('question', '').strip()
|
| 19 |
|
|
@@ -21,6 +22,7 @@ def ask_question():
|
|
| 21 |
return jsonify({"error": "Question is required"}), 400
|
| 22 |
|
| 23 |
answer = generate_long_answer(question)
|
|
|
|
| 24 |
return jsonify({"question": question, "answer": answer})
|
| 25 |
|
| 26 |
except Exception as e:
|
|
@@ -29,6 +31,8 @@ def ask_question():
|
|
| 29 |
@app.route('/get_video')
|
| 30 |
def get_video():
|
| 31 |
# Redirect user to the video URL directly
|
|
|
|
|
|
|
| 32 |
return redirect("https://videos.pexels.com/video-files/2098989/2098989-uhd_2560_1440_30fps.mp4")
|
| 33 |
|
| 34 |
|
|
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
CORS(app)
|
| 8 |
+
global_answer=""
|
| 9 |
@app.route('/health')
|
| 10 |
def health_check():
|
| 11 |
return jsonify({"status": "ready"}), 200
|
|
|
|
| 14 |
@app.route('/ask', methods=['POST'])
|
| 15 |
def ask_question():
|
| 16 |
try:
|
| 17 |
+
global global_answer
|
| 18 |
data = request.get_json()
|
| 19 |
question = data.get('question', '').strip()
|
| 20 |
|
|
|
|
| 22 |
return jsonify({"error": "Question is required"}), 400
|
| 23 |
|
| 24 |
answer = generate_long_answer(question)
|
| 25 |
+
global_answer=answer
|
| 26 |
return jsonify({"question": question, "answer": answer})
|
| 27 |
|
| 28 |
except Exception as e:
|
|
|
|
| 31 |
@app.route('/get_video')
|
| 32 |
def get_video():
|
| 33 |
# Redirect user to the video URL directly
|
| 34 |
+
globals global_answer
|
| 35 |
+
print(global_answer)
|
| 36 |
return redirect("https://videos.pexels.com/video-files/2098989/2098989-uhd_2560_1440_30fps.mp4")
|
| 37 |
|
| 38 |
|