A Beginner’s Guide to Deploying Streamlit Apps with Ngrok
To host a Streamlit app locally and expose it using Ngrok, you can follow these steps:
- Install Streamlit and Ngrok: If you haven’t already, you need to install Streamlit and Ngrok. You can install Streamlit using pip:
- You can download Ngrok from their official website and follow their installation instructions.
- Create a Streamlit App File: Save your Streamlit code in a Python file, e.g.,
streamlit_app.py
. - Create a Ngrok Tunnel: Open a terminal window and navigate to the directory where your Streamlit app file is located. Then, run the following command to create an Ngrok tunnel:
ngrok http 8501
This command tells Ngrok to create a tunnel for the local Streamlit app running on port 8501 (the default port for Streamlit).
Access Your Streamlit App: After running the Ngrok command, you will see a public URL in the terminal (e.g., http://randomstring.ngrok.io
). You can access your Streamlit app by visiting this URL in your web browser.
Now, you have a publicly accessible URL that points to your locally running Streamlit app. Users can access your app through this URL. Keep in mind that this URL will remain active as long as your Ngrok session is running. You can stop the Ngrok session by pressing Ctrl + C
in the terminal.
By following these steps, you can create a web-based application how to set up and host a Streamlit app locally using Ngrok.