-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
45 lines (31 loc) · 1.04 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask, redirect, request
# For flashing a message
from flask import flash
# For rendering html templates
from flask import render_template
# For linking files, generates a URL
from flask import url_for
# Import our forms
from forms import LinkForm
from summarize import sum_it_up
# intatiates flask app, configures the application
app = Flask(__name__)
app.config['SECRET_KEY'] = 'This is a secret'
@app.route("/summary", methods=["GET", "POST"])
def summary():
form = LinkForm()
# u = request.args.get("url")
u = form.link.data
text, keywords = sum_it_up(u)
if form.validate_on_submit():
flash(f'Summarized!', 'success')
return render_template('summary.html', form=form, text=text, u=u, keywords=keywords)
@app.route("/", methods=['GET', 'POST'])
def main():
form = LinkForm()
if form.validate_on_submit():
flash(f'Correct input!', 'success')
return redirect(url_for('main'))
return render_template('index.html', form=form)
if __name__ == '__main__':
app.run()