I have developed a Streamlit application,then I use streamlit run XXX.py,it will allow me to open the url to visit.But if after some times no active connection from this url,I visit again,it can’t not access this url again.How can I solve this issue?
You can use the
status_code parameter when running
requests.get on a URL. If it returns
200 then it means the request was successful and based on this you can use conditionals to make a decision on what to do next.
Hope this helps!
import requests response = requests.get('https://streamlit.io/') if response.status_code == 200: print('Yay!') else: print('Oh no!')