-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
71 lines (44 loc) · 1.82 KB
/
Copy pathapp.py
File metadata and controls
71 lines (44 loc) · 1.82 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import modules.functions
import os
import sys
from flask import Flask, render_template, request, redirect, url_for
current_file = os.path.abspath(__file__)
current_directory = os.path.dirname(current_file)
os.chdir(current_directory)
PORT = 9001
DEBUG_MODE = False
base_dir = '.'
if hasattr(sys, '_MEIPASS'):
base_dir = os.path.join(sys._MEIPASS)
app = Flask(__name__,
static_folder=os.path.join(base_dir, 'static'),
template_folder=os.path.join(base_dir, 'templates'))
# app.config['SERVER_NAME'] = f'localhost:{PORT}' # replace with your hostname and port number
app.config['APPLICATION_ROOT'] = '/' # replace with your root URL
app.config['PREFERRED_URL_SCHEME'] = 'https' # replace with your preferred URL scheme
app.app_context().push()
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
if 'action' in request.form and request.form['action'] == 'Add task':
user_input = request.form['input']
modules.functions.AddTask(user_input)
return redirect(url_for('index'))
tasks = modules.functions.GetTasks()
rows = ["id", "name", "check", "created_at", "archive"]
tasks_dictionary = [dict(zip(rows, item)) for item in tasks]
#print(tasks_dictionary)
return render_template('/index.html', tasks = tasks, tasks_dictionary = tasks_dictionary)
@app.route('/tick', methods=['GET', 'POST'])
def index_tick():
data = request.get_json()
state = 1 if data['activated'] else 0
modules.functions.TickTask(data['id'], state)
return "Success"
@app.route('/archive', methods=['GET', 'POST'])
def index_archive():
data = request.get_json()
modules.functions.Archive(data['id'])
return "Success"
if __name__ == '__main__':
app.run(host="0.0.0.0", debug = DEBUG_MODE, port = 9901)