-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
26 lines (21 loc) · 793 Bytes
/
demo.py
File metadata and controls
26 lines (21 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from sentiment_classifier import SentimentClassifier
from codecs import open
import time
from flask import Flask, render_template, request
app = Flask(__name__)
print("Preparing classifier")
start_time = time.time()
classifier = SentimentClassifier()
print("Classifier is ready")
print(time.time() - start_time, "seconds")
@app.route("/", methods=["POST", "GET"])
def index_page(text="", prediction_message=""):
if request.method == "POST":
text = request.form["text"]
if text!="":
prediction_message = classifier.get_prediction_message(text)
else:
prediction_message = "Пожалуйста, введите отзыв"
return render_template('hello.html', text=text, prediction_message=prediction_message)
if __name__ == "__main__":
app.run()