|
import streamlit as st |
|
import json |
|
|
|
def calculate_food(activity, weight): |
|
if activity and weight: |
|
calculated_amount = round(activity / weight, 2) |
|
return {"recommendedFood": calculated_amount} |
|
else: |
|
return {"error": "Please provide both activity level and weight."} |
|
|
|
|
|
def app(): |
|
|
|
try: |
|
data = st.json_request() |
|
activity = data.get("activity") |
|
weight = data.get("weight") |
|
print("Activity and data recieved") |
|
except: |
|
st.json({"error": "Invalid JSON data"}) |
|
return |
|
|
|
|
|
result = calculate_food(activity, weight) |
|
|
|
|
|
st.json(result) |
|
|
|
|
|
if __name__ == "__main__": |
|
app() |
|
|