shivapaka commited on
Commit
31a082a
·
verified ·
1 Parent(s): 9eb4fe5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template
2
+ from transformers import pipeline
3
+
4
+ app = Flask(__name__)
5
+
6
+ # Load the sentiment-analysis pipeline
7
+ sentiment_analysis = pipeline("sentiment-analysis")
8
+
9
+ @app.route('/')
10
+ def home():
11
+ return render_template('index.html')
12
+
13
+ @app.route('/analyze', methods=['POST'])
14
+ def analyze():
15
+ text = request.form['text']
16
+ result = sentiment_analysis(text)
17
+ return render_template('result.html', text=text, result=result)
18
+
19
+ if __name__ == '__main__':
20
+ app.run(debug=True)