Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript-jQuery.py
More file actions
Latest commit
45 lines (33 loc) · 1.18 KB
/
Copy pathjavascript-jQuery.py
File metadata and controls
45 lines (33 loc) · 1.18 KB
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
fromflaskimportFlask, url_for, render_template, request, redirect
fromflask_bootstrapimportBootstrap
importdb_interaction
app=Flask(__name__)
Bootstrap(app)
@app.route('/')
defhello_world():
# if no address is given, redirect to the index page
returnredirect(url_for('index'))
@app.route('/index.html')
defindex():
tasks_list=db_interaction.get_tasks()
returnrender_template('index.html', tasks_list=tasks_list)
@app.route('/insert_task', methods=['POST'])
definsert_task():
if ('description'inrequest.formandrequest.form['description']!=''):
description=request.form['description']
if ('urgent'inrequest.formandrequest.form['urgent'] =='on'):
urgent=1
else:
urgent=0
db_interaction.insert_task(description, urgent)
# back to the home page
returnredirect(url_for('index'))
@app.route('/delete_task', methods=['GET'])
defdelete_task():
if'id_task'inrequest.args:
id_task=request.args.get('id_task')
db_interaction.remove_task_by_id(id_task)
# back to the home page
returnredirect(url_for('index'))
if__name__=='__main__':
app.run(debug=True)