How to run Flask App on Google Colab?
Flask is a web framework in python language. This means flask provides you with tools, libraries and technologies that allow you to build a web application. This web application can be some web pages, a blog, a wiki or go as big as a web-based calendar application or a machine learning webapp.
Google Colab provides a VM(virtual machine) so we cannot access the localhost(all it does it route it to our local machine’s localhost) as we do on our local machine when running a local web server. What we can do is expose it to a public URL using ngrok. Here comes the Python library flask-ngrok.
Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.
How to use Flask on Google Colab?
To create google colab file go to this link:
1) Create new notebook in google colab
2) Install library in google colab
!pip install flask-ngrok
Flask is already install on google colab so you don’t need to install it again.
3) After that lets create a simple flask app
4) To run the code on google colab press shift+enter.
Click on this link to get the output: