Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,14 @@ classifier = pipeline("text-classification", model="j-hartmann/emotion-english-d
|
|
6 |
|
7 |
@app.route('/classify', methods=['POST'])
|
8 |
def classify():
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
@app.route('/classify', methods=['POST'])
|
8 |
def classify():
|
9 |
+
try:
|
10 |
+
data = request.get_json()
|
11 |
+
if 'text' not in data:
|
12 |
+
return jsonify({"error": "Missing 'text' field"}), 400
|
13 |
+
|
14 |
+
text = data['text']
|
15 |
+
result = classifier(text)
|
16 |
+
return jsonify(result)
|
17 |
+
|
18 |
+
except Exception as e:
|
19 |
+
return jsonify({"error": str(e)}), 500
|