Nechba commited on
Commit
1379c69
·
verified ·
1 Parent(s): ce797b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
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
- text = request.json['text']
10
- result = classifier(text)
11
- return jsonify(result)
 
 
 
 
 
 
 
 
 
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