File size: 838 Bytes
a78363f
831d153
4ca46dc
b347104
831d153
b347104
 
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
import streamlit as st
from streamlit.components.v1 import html

# Directly access query parameters without a separate function
def main():
    # Access query parameters directly
    query_params = st.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()