
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
A custom streamlit component for performing a page redirect programmatically. This is helpful since it is often required to perform a redirect, for instance after a button click or login. The streamlit-redirect component solves this by inserting a <meta> tag which directly triggers a browser redirect
A lightweight Streamlit component for performing page redirects programmatically. This component is helpful when you need to redirect users to external URLs, for instance after a button click, form submission, or successful login.
pip install streamlit-redirect
import streamlit as st
from streamlit_redirect import redirect
st.title("My App")
# Redirect after button click
if st.button("Go to Google"):
redirect("https://www.google.com")
# Redirect based on user input
url = st.text_input("Enter a URL:")
if url:
redirect(url)
redirect(url: str)
Redirects the current page to the specified URL.
Parameters:
url
(str): The target URL to redirect to. External websites must include the protocol (http://
or https://
)Note: The redirect function inserts a <meta http-equiv="refresh">
tag in the page header to perform the redirect. Make sure to only use trusted URLs to prevent security issues.
import streamlit as st
from streamlit_redirect import redirect
st.title("Welcome to My App")
col1, col2, col3 = st.columns(3)
with col1:
if st.button("🏠 Home", use_container_width=True):
redirect("https://mywebsite.com")
with col2:
if st.button("📧 Contact", use_container_width=True):
redirect("https://mywebsite.com/contact")
with col3:
if st.button("📱 About", use_container_width=True):
redirect("https://mywebsite.com/about")
import streamlit as st
from streamlit_redirect import redirect
st.title("Login Form")
with st.form("login_form"):
username = st.text_input("Username")
password = st.text_input("Password", type="password")
submitted = st.form_submit_button("Login")
if submitted:
# Your authentication logic here
if authenticate_user(username, password):
st.success("Login successful! Redirecting...")
redirect("https://myapp.com/dashboard")
else:
st.error("Invalid credentials")
import streamlit as st
from streamlit_redirect import redirect
import re
def is_valid_url(url):
pattern = re.compile(
r'^https?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' # domain...
r'localhost|' # localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
return pattern.match(url) is not None
st.title("URL Redirector")
url_input = st.text_input(
"Enter a URL to redirect to:",
placeholder="https://example.com"
)
if url_input:
if is_valid_url(url_input):
st.success(f"✅ Valid URL: {url_input}")
if st.button("Redirect Now"):
redirect(url_input)
else:
st.error("❌ Please enter a valid URL with http:// or https://")
import streamlit as st
from streamlit_redirect import redirect
import time
st.title("Redirect with Countdown")
if st.button("Start Countdown Redirect"):
placeholder = st.empty()
for i in range(5, 0, -1):
placeholder.info(f"Redirecting to Google in {i} seconds...")
time.sleep(1)
placeholder.success("Redirecting now!")
redirect("https://www.google.com")
The streamlit-redirect
component works by injecting a HTML meta refresh tag into the page:
<meta http-equiv="refresh" content="0; url=https://example.com">
This causes the browser to immediately redirect to the specified URL. The component uses Streamlit's st.markdown()
with unsafe_allow_html=True
to insert this tag.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache-2.0 License - see the LICENSE file for details.
If you encounter any issues or have questions, please file an issue on the GitHub repository.
FAQs
A custom streamlit component for performing a page redirect programmatically. This is helpful since it is often required to perform a redirect, for instance after a button click or login. The streamlit-redirect component solves this by inserting a <meta> tag which directly triggers a browser redirect
We found that streamlit-redirect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.