Spaces:
Sleeping
Sleeping
Download app.py from sreepathi-ravikumar/sample: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/sreepathi-ravikumar/sample/resolve/main/app.py
- Command line
-
hf download hf://spaces/sreepathi-ravikumar/sample/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sreepathi-ravikumar/sample/resolve/main/app.py
1.21 kB
| 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) | |
| def health_check(): | |
| return jsonify({"status": "ready"}), 200 | |
| # Standard answer route | |
| 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 | |
| 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) |