I want to be able to have special treatment of my Streamlit app depending on some QueryString params.
I’m able to test these querystrings on the browser, but if I attempt using python request.get() to simulate a call with querystring params I always get access denied errors. My app doesn’t have any auth methods anywhere.
Why am I only able to use Streamlit in a browser but not on a simple requests.get() call? Do I need some special params on this call?
I got around this “access denied” issue. It was actually a proxy problem.
No I am managing to call Streamlit either from a python requests() call or via cURL.
But I always receive a response like the one below. I am pasting my very simple code which is not working as expected, I never get the “querystring if” to work.
ingest-upload) [ec2-user@ip-172-16-1-126 ingest-upload]$ curl http://localhost:8501?test=upload
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon"href="./favicon.png"/><title>Streamlit</title><script>window.prerenderReady=!1</script><script src="./vendor/viz/viz-1.8.0.min.js" type="javascript/worker"></script><script src="./vendor/bokeh/bokeh-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-widgets-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-tables-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-api-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-gl-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-mathjax-2.4.3.min.js"></script><script defer="defer" src="./static/js/main.8a695abc.js"></script><link href="./static/css/main.f4a8738f.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>(ingest-upload) [ec2-user@ip-172-16-1-126 ingest-upload]$
Here’s what I’m trying to do:
import streamlit as st
import os
query_params = st.experimental_get_query_params()
print(query_params)
if not query_params:
st.title('Streamlit Homepage')
print('No query string')
else:
if query_params:
print('There is a query string:')
print(query_params)
Streamlit is a framework for converting python code to a web app. That web app requires javascript to render. There is no version of streamlit that doesn’t require javascript to render.
However, there are alternatives to vanilla requests that do support running javascript, such as requests-html · PyPI
But, if you simply want to serve simple data in response to query params, and don’t actually want a UI frontend, then you would probably be better off using something like FastAPI or Flask.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.