Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, render_template
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load sentiment-analysis pipeline
|
5 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
6 |
+
|
7 |
+
app = Flask(__name__)
|
8 |
+
|
9 |
+
@app.route("/", methods=["GET", "POST"])
|
10 |
+
def index():
|
11 |
+
result = None
|
12 |
+
if request.method == "POST":
|
13 |
+
text = request.form["text"]
|
14 |
+
result = sentiment_pipeline(text)[0]
|
15 |
+
return render_template("index.html", result=result)
|
16 |
+
|
17 |
+
if __name__ == "__main__":
|
18 |
+
app.run(debug=True)
|