Spaces:
Sleeping
Sleeping
from flask import Flask, request, jsonify | |
from gradio_client import Client | |
import os | |
app = Flask(__name__) | |
def ask_question(): | |
try: | |
input_text = request.json.get("text") | |
print("INPUT:", input_text) | |
if not input_text: | |
return jsonify({"error": "Missing 'text'"}), 400 | |
client = Client("memorease/memorease-flan-t5") | |
result = client.predict(input_text, api_name="/predict") | |
print("RESULT:", result) | |
return jsonify({"question": result}) | |
except Exception as e: | |
print("SERVER ERROR:", str(e)) | |
return jsonify({"error": str(e)}), 500 | |
def index(): | |
return "Flan5 Memorease Docker Space is running!", 200 | |
if __name__ == "__main__": | |
port = int(os.environ.get("PORT", 7860)) | |
app.run(host="0.0.0.0", port=port) | |