Issue
I'm working on a project using Django for user authentication and Streamlit for the front end. I'm struggling to fetch the authenticated user's information from Django and pass it to my Streamlit app.
How can I efficiently retrieve user data from Django and securely transfer it to Streamlit? Any guidance or code examples for this integration would be appreciated. Thanks!
Attempted to establish communication between Django and Streamlit by creating an endpoint in Django to fetch user information. I expected to retrieve the authenticated user's data from Django and then use an HTTP request in Streamlit to fetch this data from the Django endpoint. However, I encountered difficulties in properly implementing this communication and handling the data transfer securely between the two platforms.
Also Tried to Use Javascript To Fetch On Screen Infomration
Solution
Pass The Username As Parameter From Django
Django Templated Code:-
<iframe src="http://localhost:8501/?username={{ request.user.username }}"></iframe>
Streamlit code :-
import streamlit as st
import urllib.parse
# Get URL parameters from Streamlit's URL
url_params = st.experimental_get_query_params()
# Get the username from the URL parameters
username = url_params.get('username', [''])[0]
st.write("Received username from URL:", username)
# Process the received username in Streamlit
Answered By - Jay Padhiyar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.