-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
25 lines (20 loc) · 798 Bytes
/
app.py
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
from flask import Flask, render_template, flash, redirect
from flask_bootstrap import Bootstrap
from config import Config
from form import InputForm
from model import Analyzer
app = Flask(__name__)
bootstrap = Bootstrap(app)
app.config.from_object(Config)
app.config["analyzer"] = Analyzer(model="2020-03-15T23:57:24--acc--0.846.pt")
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index():
form = InputForm()
if form.validate_on_submit():
flash("Analyzing Text...")
sentences, labels = app.config["analyzer"].analyze(form.text.data)
return render_template('result.html', sentences=sentences, labels=labels)
return render_template('index.html', title='Analyze', form=form)
if __name__ == '__main__':
app.run()