Spaces:
Sleeping
Sleeping
File size: 957 Bytes
a78363f 831d153 4ca46dc 831d153 12d4b63 ab31bb5 831d153 80d39a9 831d153 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import streamlit as st
from streamlit.components.v1 import html
# Function to extract query parameters
def get_query_params():
# Use st.query_params to access query parameters
return st.query_params()
# Main function where we handle the redirect
def main():
# Get query parameters
query_params = get_query_params()
# Check if 'param1' exists in the query parameters
if 'param1' in query_params:
# Extract the first value of 'param1'
redirect_url = query_params['param1'][0]
# Use JavaScript to redirect to the URL provided in 'param1'
js = f"""
<script>
window.location.href = "{redirect_url}";
</script>
"""
html(js) # Use Streamlit's HTML component to run the JavaScript
else:
# If 'param1' is not present, display a message
st.write("No redirect URL provided in query parameters.")
if __name__ == "__main__":
main()
|