Spaces:
Sleeping
Sleeping
Commit
•
15b89f6
1
Parent(s):
778672f
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,33 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
# Dummy data for the sake of simplicity
|
6 |
-
# In a real application, you might store this in a database
|
7 |
exercises = ["Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5", "Exercise 6", "Exercise 7", "Exercise 8"]
|
8 |
exercise_counts = {exercise: 0 for exercise in exercises}
|
9 |
total_exercises_completed = 0
|
10 |
days_completed = 0
|
11 |
|
12 |
-
|
13 |
-
def
|
14 |
-
|
15 |
-
|
16 |
-
@app.route('/reset', methods=['POST'])
|
17 |
-
def reset():
|
18 |
-
global total_exercises_completed, days_completed
|
19 |
all_completed = all(count >= 6 for count in exercise_counts.values())
|
20 |
if all_completed:
|
21 |
days_completed += 1
|
22 |
for exercise in exercises:
|
23 |
exercise_counts[exercise] = 0
|
24 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
|
3 |
+
# Replicating your Flask dummy data and logic
|
|
|
|
|
|
|
4 |
exercises = ["Exercise 1", "Exercise 2", "Exercise 3", "Exercise 4", "Exercise 5", "Exercise 6", "Exercise 7", "Exercise 8"]
|
5 |
exercise_counts = {exercise: 0 for exercise in exercises}
|
6 |
total_exercises_completed = 0
|
7 |
days_completed = 0
|
8 |
|
9 |
+
# Function to mimic the reset logic from Flask, now to be used in Gradio interface
|
10 |
+
def reset_exercises():
|
11 |
+
global days_completed, exercise_counts
|
|
|
|
|
|
|
|
|
12 |
all_completed = all(count >= 6 for count in exercise_counts.values())
|
13 |
if all_completed:
|
14 |
days_completed += 1
|
15 |
for exercise in exercises:
|
16 |
exercise_counts[exercise] = 0
|
17 |
+
return "Exercise counts have been reset!"
|
18 |
+
|
19 |
+
# Function to display current exercise status, mimicking the homepage in Flask
|
20 |
+
def display_exercises():
|
21 |
+
exercise_status = "\n".join([f"{exercise}: {count}" for exercise, count in exercise_counts.items()])
|
22 |
+
return f"Current Exercises:\n{exercise_status}\n\nTotal Exercises Completed: {total_exercises_completed}\nDays Completed: {days_completed}"
|
23 |
+
|
24 |
+
# Gradio interface to display exercises and reset counts
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=lambda: display_exercises(),
|
27 |
+
inputs=gr.buttons(["Reset Exercises"], fn=reset_exercises),
|
28 |
+
outputs="text",
|
29 |
+
title="Physical Therapy Tracker",
|
30 |
+
description="Track and reset your physical therapy exercises."
|
31 |
+
)
|
32 |
+
|
33 |
+
iface.launch()
|