memorease commited on
Commit
69f9211
·
verified ·
1 Parent(s): 537c1d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -7,18 +7,21 @@ app = Flask(__name__)
7
  @app.route("/ask", methods=["POST"])
8
  def ask_question():
9
  try:
10
- print(">>> REQUEST ARRIVED")
 
11
 
12
- print(">>> HEADERS:", request.headers)
13
- print(">>> RAW BODY:", request.data)
14
- print(">>> JSON:", request.get_json())
15
 
16
- return jsonify({"status": "received"}), 200
 
 
 
 
17
  except Exception as e:
18
- print(">>> SERVER ERROR:", str(e))
19
  return jsonify({"error": str(e)}), 500
20
 
21
-
22
  @app.route("/", methods=["GET"])
23
  def index():
24
  return "Flan5 Memorease Docker Space is running!", 200
 
7
  @app.route("/ask", methods=["POST"])
8
  def ask_question():
9
  try:
10
+ input_text = request.json.get("text")
11
+ print("INPUT:", input_text)
12
 
13
+ if not input_text:
14
+ return jsonify({"error": "Missing 'text'"}), 400
 
15
 
16
+ client = Client("memorease/memorease-flan-t5")
17
+ result = client.predict(input_text, api_name="/predict")
18
+
19
+ print("RESULT:", result)
20
+ return jsonify({"question": result})
21
  except Exception as e:
22
+ print("SERVER ERROR:", str(e))
23
  return jsonify({"error": str(e)}), 500
24
 
 
25
  @app.route("/", methods=["GET"])
26
  def index():
27
  return "Flan5 Memorease Docker Space is running!", 200