Run Streamlit App on Colab without Ngrok (LocalTunnel)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
dear fellow coders welcome to one little quarter let's talk about a problem that a lot of us face you have got a google collab that is available with gpu and tpu and you want to run a streamlit application on google collab it's not as straightforward as it might look like because the way you run a streamlit application when it is on your local machine is you just have to basically say um streamlit run app.pipe yeah so this is how you typically run a streamlight application if it is on your local machine but that is not possible for you to do it on a google column environment straight away because you will get a local host url which is you know applicable for that linux machine that you are getting on google collab but you may not be able to see that link somewhere on so you cannot share that link with your friends and the typical solution that people use for this kind of problem is ngrok ngrok is an amazing solution but ngrok is not the only solution that you can use so in this video i'm going to show you how you can run host and share a google collab notebook sorry streamlight application on a google collab notebook without ingrock and the solution that we're going to look at is particularly called local tunnel so before we look into local tunnel let us start building a streamlight simple stimulated application and then let's see how to run it without any rock and on google collab environment so once you open your google collab environment pip install streamlit quietly install it it's a queue after you install it you have to create your simulated application i've created very simple stream load application and the first step that i have to do is i have to write the streamlit application whatever is available in this code i want to write it in app.pi file so execute this at the end of this step you would see writingapp.pi file and you can go to your file section and you can see that the file exists so for us to run this app.pi file we have to run the content of the cell within a python file so you don't have to manually go export it and upload it you don't have to do any of those things all you have to do is simply write the cell python code into uh an app.pi file okay so after you do that then the typical step that people follow is in install pi ngrok and then you know invoking grock and then return a port and then see but that's not what we are going to do here what we are going to do here is we are going to use a solution called local channel so local tunnel is the solution that we are interested in at this point to run streamlight application on google collab and share the link let me run this and then when it is being run i'm going to show you more about local term so in in my current case it happened very fast because local tunnel has been already installed in this particular instance of google cola it may not be same for your instance so at this point you can see streamlit app has been run and then we are also tunneling the port where the streamlet application is running which is 8501 we are channeling it into this url let me click this once i click this you know what it is going to say it's going to say that you know you are entering into you know a website that is served into local tunnel i think this is the information that um that that that has been shown as like a disclaimer or something so that people people know that you are proceeding into because a lot of people who you who try to fish ph ish so a lot of people who try to fish would probably use a solution like that and that that's why this disclaimer is available so if you want to bypass this page there are options that are available for you to bypass this but let's click to continue after you click to continue you should be able to see your streamlight application which says hello world run streamlit on collab without without using any clock so at this point you have a successful streamlet application running on google collab and tunnel to the entire world to the internet especially through local tunnel now this is an entire setup happening completely on google collab so we which means you can build a streamlit application that leverages gpu and then you can still run it on google collab and then share the link with anybody on the internet like on the planet which which means like you can see um like you can share the link and anybody can see it it's completely free solution and very simple less number of dependencies all you need is npm to install local tunnel so now what is local channel so local tunnel is nothing but you know it's a it's a library um specifically like it's an npl npm library you can install local channel that would expose your local host to the world so it's easy for testing and sharing you don't have to do anything else you don't need an external you know library or a page solution um you don't need any of those things after you install local tunnel all you have to do is npx local channel to invoke the local channel and call the port the like one of the parameters that you would pass is the port number that you want to tunnel it and then at the end you're going to have you're going to have it tunneled to the link a link where you can start seeing like a link like this now coupling that because you have already got npm on your google collab environment the first time when you run this thing it's going to install local tunnels so the first time it's going to take a little bit of time couple of minutes but after you do that every time it's going to take a couple of seconds like in our case it took only four seconds and you can have your port tunneled and when you don't want this to happen when you want to stop it see again you can you can actually see this thing but when you want this to stop you can just stop this and when you click this link when you refresh this link this would not work anymore because it's a photo for a right page not phone because your app has been shut down so the server is shut down the link that you shared with your friends or you know the social media potential employer is not valid anymore so very simple step very few lines of python code you can run streamlined on google collab without ngrog through local tunnel let me quickly revise you install the streamlet application write the streamlit applications code in a nav.pi file you don't need any other external dependency when you run this command for the first time which is to run streamlit app.pi and also local tunnel invoking local tunnel it would install local tunnel by default so you don't have to manually install it and then you tunnel the port 8501 and at the end of this process you would get a link which let me show you which once you click you would get a disclaimer message or a warning message for the first time this is for people to this is for people to know that it's a it's a tunnel link so especially like if somebody's trying to fish or something you know this should prevent them like it's a caution but if you click it you would land on that streamlit application if you want to bypass that you can still bypass it that's what you get in the first page but otherwise you know you can happily share your stimulated application with anybody on the world and then you can see more about local tunnel in this github repository which i would link in the youtube description if you are watching until now thank you so much for sticking um till the end i hope this video was helpful to you and quickly prototyping and testing your streamlight application without any hesitation and also on any mission right you don't need a local machine you don't need anything or local you can test this on just a google collab environment even on your mobile phone android phone ipad or any any you know device that has got a browser so if you find this video helpful please let me know in the comment section otherwise if you have any feedback let me know in the comment section as well stay safe take care of yourself happy coding
Info
Channel: 1littlecoder
Views: 32,594
Rating: undefined out of 5
Keywords:
Id: NEhrkeF2o_M
Channel Id: undefined
Length: 7min 41sec (461 seconds)
Published: Wed Oct 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.