memorease commited on
Commit
537c1d0
·
verified ·
1 Parent(s): 254633b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -20
app.py CHANGED
@@ -7,29 +7,15 @@ app = Flask(__name__)
7
  @app.route("/ask", methods=["POST"])
8
  def ask_question():
9
  try:
10
- print("REQUEST RECEIVED")
11
 
12
- if not request.is_json:
13
- print("BAD REQUEST: Not JSON")
14
- return jsonify({"error": "Expected JSON"}), 400
15
 
16
- input_data = request.get_json()
17
- print("JSON PAYLOAD:", input_data)
18
-
19
- input_text = input_data.get("text")
20
- print("INPUT TEXT:", input_text)
21
-
22
- if not input_text:
23
- print("BAD REQUEST: 'text' missing")
24
- return jsonify({"error": "Missing 'text'"}), 400
25
-
26
- client = Client("memorease/memorease-flan-t5")
27
- result = client.predict(input_text, api_name="/predict")
28
-
29
- print("MODEL RESULT:", result)
30
- return jsonify({"question": result})
31
  except Exception as e:
32
- print("SERVER ERROR:", str(e))
33
  return jsonify({"error": str(e)}), 500
34
 
35
 
 
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