-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (41 loc) · 1.28 KB
/
Copy pathmain.py
File metadata and controls
53 lines (41 loc) · 1.28 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
46
47
48
49
50
51
52
53
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__)
tasks=[]
task_id_counter = 1
@app.route('/')
def main():
return render_template('main.html', tasks=tasks)
@app.route('/task')
def task():
return render_template('task.html')
@app.route('/submit', methods=['POST'])
def handle_submit():
global task_id_counter
title = request.form.get('title')
task_input = request.form.get('task_input')
data = request.form.get('data')
if task_input:
task_data = {
'id': task_id_counter,
'task_input': task_input,
'title': title,
'date': data,
'status': 'В процессе',
'completed': False
}
tasks.append(task_data)
task_id_counter += 1
return redirect(url_for('main'))
@app.route('/complete/<int:task_id>')
def complete_task(task_id):
for task in tasks:
if task['id'] == task_id:
task['status'] = 'Выполнено'
task['completed'] = True
break
return redirect(url_for('main'))
@app.route('/history_task')
def history_task():
return render_template('history_task.html', tasks=tasks)
if __name__ == '__main__':
app.run(debug=True, port=5000)