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.