Notification texts go here Contact Us Buy Now!

Allow users to update secrets on a running Streamlit app?

Regrettably, there isn't currently a way to enable end users of the app to set secrets. The optimal alternative at this point in time is to generate a st.text_input field to allow users to input their own API key.

Here's a code snippet that demonstrates how to use the st.text_input field to allow users to enter their API key:

import streamlit as st

# Create a text input field for the user to enter their API key
api_key = st.text_input("Enter your API key")

# Use the API key to make a request to an API
response = requests.get("https://example.com/api/v1/data", headers={"Authorization": f"Bearer {api_key}"})

# Display the response from the API
st.write(response.json())

This approach provides a simple and straightforward way for users to provide their own API key, while maintaining the security of your Streamlit app.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.