leobora commited on
Commit
5ca9945
·
verified ·
1 Parent(s): 8095fcc

Add FastAPI backend and integrate with Gradio frontend for workout plan generation

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,7 +1,29 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import requests
3
 
4
+ def get_workout_plan(weight, height, age, body_type, goals, preferences):
5
+ response = requests.post("http://127.0.0.1:8000/generate_plan", json={
6
+ "weight": weight,
7
+ "height": height,
8
+ "age": age,
9
+ "body_type": body_type,
10
+ "goals": goals,
11
+ "preferences": preferences
12
+ })
13
+ return response.json()
14
 
15
+ with gr.Blocks() as demo:
16
+ with gr.Row():
17
+ weight = gr.Number(label="Weight (kg)")
18
+ height = gr.Number(label="Height (cm)")
19
+ age = gr.Number(label="Age")
20
+ body_type = gr.Dropdown(choices=["Active", "Sedentary"], label="Body Type")
21
+ goals = gr.Textbox(label="Goals")
22
+ preferences = gr.Textbox(label="Preferences")
23
+
24
+ workout_plan = gr.Textbox(label="Generated Workout Plan")
25
+
26
+ generate_button = gr.Button("Generate Plan")
27
+ generate_button.click(get_workout_plan, [weight, height, age, body_type, goals, preferences], workout_plan)
28
+
29
+ demo.launch()