-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript-jQuery.py
More file actions
45 lines (33 loc) · 1.18 KB
/
javascript-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
from flask import Flask, url_for, render_template, request, redirect
from flask_bootstrap import Bootstrap
import db_interaction
app = Flask(__name__)
Bootstrap(app)
@app.route('/')
def hello_world():
# if no address is given, redirect to the index page
return redirect(url_for('index'))
@app.route('/index.html')
def index():
tasks_list = db_interaction.get_tasks()
return render_template('index.html', tasks_list=tasks_list)
@app.route('/insert_task', methods=['POST'])
def insert_task():
if ('description' in request.form and request.form['description']!=''):
description = request.form['description']
if ('urgent' in request.form and request.form['urgent'] == 'on'):
urgent = 1
else:
urgent = 0
db_interaction.insert_task(description, urgent)
# back to the home page
return redirect(url_for('index'))
@app.route('/delete_task', methods=['GET'])
def delete_task():
if 'id_task' in request.args:
id_task = request.args.get('id_task')
db_interaction.remove_task_by_id(id_task)
# back to the home page
return redirect(url_for('index'))
if __name__ == '__main__':
app.run(debug=True)