-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.py
executable file
·46 lines (36 loc) · 1 KB
/
web.py
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
#!/usr/bin/env python3
import threading
import webbrowser
import bottle
import countMeDown
@bottle.route("/", method="GET")
def get_page():
return bottle.template("form")
@bottle.route("/", method="POST")
def handle_post():
request_args = bottle.request.forms
if request_args.mode == "mode_duration":
seconds = countMeDown.get_seconds_from_mixed_format(
request_args.get("duration")
)
else:
seconds = countMeDown.get_seconds_until_time(request_args.time)
command = threading.Thread(
target=countMeDown.count_me_down,
args=(
seconds,
request_args.prefix,
request_args.ending,
int(request_args.step),
"./time.txt",
True,
),
)
command.start()
return "yay"
if __name__ == "__main__":
server = threading.Thread(
target=bottle.run, kwargs={"host": "localhost", "port": 22222}
)
server.start()
webbrowser.open("http://localhost:22222")