Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,20 @@ app = Flask(__name__)
|
|
7 |
@app.route("/ask", methods=["POST"])
|
8 |
def ask_question():
|
9 |
try:
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
if not input_text:
|
14 |
-
print("
|
15 |
return jsonify({"error": "Missing 'text'"}), 400
|
16 |
|
17 |
client = Client("memorease/memorease-flan-t5")
|
@@ -20,9 +29,10 @@ def ask_question():
|
|
20 |
print("MODEL RESULT:", result)
|
21 |
return jsonify({"question": result})
|
22 |
except Exception as e:
|
23 |
-
print("SERVER ERROR:", str(e))
|
24 |
return jsonify({"error": str(e)}), 500
|
25 |
|
|
|
26 |
@app.route("/", methods=["GET"])
|
27 |
def index():
|
28 |
return "Flan5 Memorease Docker Space is running!", 200
|
|
|
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")
|
|
|
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 |
+
|
36 |
@app.route("/", methods=["GET"])
|
37 |
def index():
|
38 |
return "Flan5 Memorease Docker Space is running!", 200
|