File size: 877 Bytes
abb28f8
e559111
e79e34b
abb28f8
ad9dfac
ca835bb
82ddab9
abb28f8
 
69f9211
 
254633b
69f9211
 
254633b
69f9211
 
 
 
 
abb28f8
69f9211
abb28f8
ad9dfac
82ddab9
 
 
abb28f8
ad9dfac
e79e34b
ad9dfac
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
from flask import Flask, request, jsonify
from gradio_client import Client
import os

app = Flask(__name__)

@app.route("/ask", methods=["POST"])
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

@app.route("/", methods=["GET"])
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)