Spaces:
Sleeping
Sleeping
Commit
•
e8dca06
1
Parent(s):
93f488c
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,48 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
|
4 |
# Initialize counters and logs
|
5 |
total_exercises_completed = 0
|
6 |
days_completed = 0
|
7 |
-
last_reset =
|
8 |
-
exercise_log = {
|
9 |
|
10 |
def reset_tracker():
|
11 |
global total_exercises_completed, days_completed, last_reset, exercise_log
|
12 |
-
if
|
13 |
all_done_today = all(count >= 6 for count in exercise_log.values())
|
14 |
if all_done_today:
|
15 |
days_completed += 1
|
16 |
-
last_reset =
|
17 |
-
exercise_log = {
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
iface = gr.Interface(
|
22 |
-
fn=
|
23 |
-
inputs=gr.
|
24 |
outputs=[
|
25 |
-
gr.Textbox(label="Exercise Log", lines=10, value="
|
26 |
-
gr.
|
27 |
-
gr.
|
28 |
-
]
|
|
|
|
|
29 |
|
30 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from datetime import date, timedelta
|
3 |
|
4 |
# Initialize counters and logs
|
5 |
total_exercises_completed = 0
|
6 |
days_completed = 0
|
7 |
+
last_reset = date.today() - timedelta(days=1)
|
8 |
+
exercise_log = {f"Exercise {i+1}": 0 for i in range(8)}
|
9 |
|
10 |
def reset_tracker():
|
11 |
global total_exercises_completed, days_completed, last_reset, exercise_log
|
12 |
+
if date.today() > last_reset:
|
13 |
all_done_today = all(count >= 6 for count in exercise_log.values())
|
14 |
if all_done_today:
|
15 |
days_completed += 1
|
16 |
+
last_reset = date.today()
|
17 |
+
exercise_log = {f"Exercise {i+1}": 0 for i in range(8)}
|
18 |
+
return exercise_log, total_exercises_completed, days_completed
|
19 |
+
|
20 |
+
def update_exercise(exercise_num):
|
21 |
+
global exercise_log, total_exercises_completed
|
22 |
+
if date.today() > last_reset:
|
23 |
+
reset_tracker()
|
24 |
+
exercise_name = f"Exercise {exercise_num}"
|
25 |
+
if exercise_log[exercise_name] < 6:
|
26 |
+
exercise_log[exercise_name] += 1
|
27 |
+
total_exercises_completed += 1
|
28 |
+
return exercise_log, total_exercises_completed, days_completed
|
29 |
+
|
30 |
+
def get_exercise_status():
|
31 |
+
global exercise_log, total_exercises_completed, days_completed
|
32 |
+
return "\n".join(f"{name}: {count}" for name, count in exercise_log.items()), total_exercises_completed, days_completed
|
33 |
+
|
34 |
+
reset_button = gr.Button("Reset Daily Tracker")
|
35 |
+
exercise_buttons = [gr.Button(f"Exercise {i+1}") for i in range(8)]
|
36 |
|
37 |
iface = gr.Interface(
|
38 |
+
fn=get_exercise_status,
|
39 |
+
inputs=[gr.Number(label="Exercise Number", value=1)] + [reset_button] + exercise_buttons,
|
40 |
outputs=[
|
41 |
+
gr.Textbox(label="Exercise Log", lines=10, value=""),
|
42 |
+
gr.Number(label="Total Exercises Completed"),
|
43 |
+
gr.Number(label="Days Completed")
|
44 |
+
],
|
45 |
+
live=True
|
46 |
+
)
|
47 |
|
48 |
iface.launch()
|