I’ve got a nice running Streamlit app, and i’m using it to submit data (via the Uploader) to a backend Flask API. However, most times this Flask API can take 30 seconds to 10 minutes to complete its processing! After I submit the Uploaded file, the UI freezes until complete.
There more complicated way i suppose I could solve this is workers on the backend which could provide a response quickly saying “processing” back to Streamlit. Another approach (which is why i’m asking this question), is there a way within Streamlit to make that asyn call? Here is my code:
def post_submission(payload: dict):
api_url = f"api_url_here"
# it can take 10 min to get a response!
response = requests.post(api_url, json=payload)
return response
response = post_submission(payload)
if response.status_code == 200:
st.success("Data successfully submitted")
else:
st.warning("api is probably down")
st.write(response)
st.write(response.status_code)
Thank you