forked from AmI-2018/python-lab5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
41 lines (31 loc) · 920 Bytes
/
app.py
File metadata and controls
41 lines (31 loc) · 920 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask, redirect, render_template, url_for, \
request
import sql_db
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)
@app.route('/')
def start():
return redirect('index_bootstrap')
@app.route('/index')
def index():
list = sql_db.showAll()
return render_template("index.html", list=list)
@app.route('/index_bootstrap')
def index_bootstrap():
list = sql_db.showAll()
return render_template("index_bootstrap.html", list=list)
@app.route('/delete_task/<int:id>')
def delete_task(id):
sql_db.remove(id)
return redirect(url_for('index_bootstrap'))
@app.route('/insert_task', methods=['POST'])
def insert_task():
name = request.form['todo']
if request.form.get('urgent'):
sql_db.insert_urgent(name)
else:
sql_db.insert(name)
return redirect(url_for('index_bootstrap'))
if __name__ == '__main__':
app.run()