Skip to content

Instantly share code, notes, and snippets.

@tuffacton
Last active March 7, 2024 05:47
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save tuffacton/da5a9b42c0a2e9e355353689f93c84b3 to your computer and use it in GitHub Desktop.
Save tuffacton/da5a9b42c0a2e9e355353689f93c84b3 to your computer and use it in GitHub Desktop.
Colaboratory Notebook that hosts a streamlit app and creates an ngrok https tunnel for access.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vanapaladheerajvarma
Copy link

i read so can you please provide me code how to run steamline which diplays "Hello world" in google colab

@MemphisMeng
Copy link

i read so can you please provide me code how to run steamline which diplays "Hello world" in google colab
I guess you can only modify the codes after python -c

@Taneesha-creates
Copy link

Running this code gives me this

This site can’t be reached
35.229.140.58 took too long to respond.
Try:

Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_TIMED_OUT

@tuffacton
Copy link
Author

Hi, please just run all cells and only try to hit the URL from ngrok that's like so: http://377f47dc6ed1.ngrok.io
The IP of the colaboratory instance will not be exposed so you cannot hit those IPs.

@Taneesha-creates
Copy link

Taneesha-creates commented Jun 23, 2020 via email

@tuffacton
Copy link
Author

Thank you, I'll try that! Could I bother you again if it doesn't work? (If you don't mind, of course )

On Tue, 23 Jun 2020, 7:10 pm Nic Acton, @.> wrote: @.* commented on this gist. ------------------------------ Hi, please just run all cells and only try to hit the URL from ngrok that's like so: http://377f47dc6ed1.ngrok.io The IP of the colaboratory instance will not be exposed so you cannot hit those IPs. — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://gist.github.com/da5a9b42c0a2e9e355353689f93c84b3#gistcomment-3351739, or unsubscribe https://github.com/notifications/unsubscribe-auth/APQ2FEUEXY5IYD3GRSJ6YGLRYDAUVANCNFSM4N6CSHIQ .

You can always leave a comment and I'll get to it when I can. Please try to be verbose with the steps you took and the errors you're seeing, maybe even a link to a Colaboratory notebook that you're running it in so the errors can be reproduced.

@gabrielaugustom
Copy link

Wait. If I understand right. If I execute this code may I can use Streamlit on Google Colab? Is it?
Its the first time that I'll use Streamlit, as Data Scientist I can use matplotlib, pandas, etc, but seems very nice plot in Streamlit.

If you can help me with that, please I follow u on Instagram.
Ty, hugs from Brazil.

@gabrielaugustom
Copy link

btw I have some colab here. u can see it. Can I use Streamlit on them? Ty mf.

@tuffacton
Copy link
Author

btw I have some colab here. u can see it. Can I use Streamlit on them? Ty mf.

I took a quick look. I think you can make prototypes and develop with Streamlit on Colaboratory, but you wouldn't want to make that your production server as Colaboratory has a relatively short timeout (only about 12 hours). You can find more on how Streamlit could maybe fit with your projects here: https://www.streamlit.io/

@Hardly-Human
Copy link

Thank you so much for this brilliant piece of code.....👌👌

@Kareem-negm
Copy link

this is awesome thanks a lot

@swapniladnak2510
Copy link

when I clicked on the URL it is showing me

"Tunnel f9b2788c5740.ngrok.io not found"

@mahajanjanvi
Copy link

Hey m getting this error. could you help?
get_ipython().system_raw('./ngrok http 8501 &')
! curl -s http://localhost:4040/api/tunnels | python3 -c
"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

error: Traceback (most recent call last):
File "", line 1, in
IndexError: list index out of range

@tuffacton
Copy link
Author

when I clicked on the URL it is showing me

"Tunnel f9b2788c5740.ngrok.io not found"

Can you post a copy of your colaboratory notebook?

@tuffacton
Copy link
Author

Hey m getting this error. could you help?
get_ipython().system_raw('./ngrok http 8501 &')
! curl -s http://localhost:4040/api/tunnels | python3 -c
"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

error: Traceback (most recent call last):
File "", line 1, in
IndexError: list index out of range

Can you post a copy of your colaboratory notebook?

@swapniladnak2510
Copy link

when I clicked on the URL it is showing me
"Tunnel f9b2788c5740.ngrok.io not found"

Can you post a copy of your colaboratory notebook?

Thanks but this problem is solved. it was ngrok version issue

@sakiskun
Copy link

sakiskun commented Mar 4, 2021

Legend..thanks for demystifying it on colab. Had totally hit a wall on my own..

@IricsDo
Copy link

IricsDo commented May 24, 2021

Thanks guys! It can work in colab!
But i see some difference between run in colab and run in local.
When i run streamlit hello in local, I choose Animation Demo and run it. The Animation move move and move ...
But i run streamlit hello in colab like your code, I choose Animation Demo however the Animation don't move. only stand still
Why?

@marcel9100
Copy link

Thank you very much for this

@Aishwary-Rawal
Copy link

Hey! I am getting this error when I try opening "https://2f10-35-196-239-11.ngrok.io/" this link. Please help.

The connection to https://2f10-35-196-239-11.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:80.

Make sure that a web service is running on localhost:80 and that it is a valid address.

The error encountered was: dial tcp 127.0.0.1:80: connect: connection refused

@tuffacton
Copy link
Author

Hey! I am getting this error when I try opening "https://2f10-35-196-239-11.ngrok.io/" this link. Please help.

The connection to https://2f10-35-196-239-11.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:80.

Make sure that a web service is running on localhost:80 and that it is a valid address.

The error encountered was: dial tcp 127.0.0.1:80: connect: connection refused

Can you post a copy of your Colaboratory Notebook?

@Lyrics46
Copy link

Lyrics46 commented Feb 8, 2022

I have the same problem as you. Did you solve it?@Aishwary-Rawal
I use VPN when I am using Colab. Is the problem related to this?

@saiprasad-psp
Copy link

Hi,
I get the following error.
image

@2368401311
Copy link

I could not use this way. the localhost refused. thus, i find the other way to solve it
npx create localtunnel and show the url to check in the browse

!streamlit run app.py & npx localtunnel --p 8501

@2368401311
Copy link

Hi, I get the following error. image

try this one. only on line code

!streamlit run app.py & npx localtunnel --p 8501

@Aramatic
Copy link

https://youtu.be/zdJdJ1tHGnA , you can watch video for running streamlit in local hoast using localtunnel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment