Hi all,
I am new to Streamlit and trying to make this simple on button click call this order function. When I try to run this via Streamlit it returns None as output.
But, if I run the api.place_single_order() function in Jupyter with same arguments that returns proper order details.
What could be wrong with this?
@st.cache_resource
def api(
username,
password,
):
api = OrderSystem(
userId=username,
password=password,
)
return api
def display_dashboard(
username,
password,
):
Store = api(
username,
password,
)
with st.form(key="my_form", clear_on_submit=True):
product = st.selectbox("Select product", ("Apple", "Banana"))
qty = st.number_input(label="Quantity", min_value=1)
submit_buy = st.form_submit_button(label="Buy")
if submit_buy:
order = Store.place_single_order(
product=product,
qty=qty,
)
st.write(order)
orderid = order.no
st.write(f"Placed order with number {orderid}")
if __name__ == "__main__":
display_dashboard(
username,
password,
)
st.write basically returns None. I also tried st.text and result is the same. The code runs outside in Jupyter perfectly fine.
The app is running in docker container. Python version is 3.11 and Streamlit version is Streamlit v1.31.1