Flask Minimal Setup and Hello World with NGROK

Setup VirtualEnv, Flask Installation and Project Directory

pip3 install virtualenv
virtualenv -p /usr/bin/python3 flask-sample
source flask-sample/bin/activate
pip install flask
mkdir flask-demo && cd flask-demo
touch main.py

Edit main.py file

from flask import Flask
app = Flask(__name__)

def hello():
    return "Hello World!"

if __name__ == '__main__':

Run Flask app and visit localhost:5000

python main.py

Console Log
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on (Press CTRL+C to quit)


Signup for NGROK and get AuthToken

wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip ngrok-stable-linux-amd64.zip
./ngrok authtoken 
./ngrok http 5000
Console Log
ngrok by @inconshreveable                                                                                                                                                                                                                                       (Ctrl+C to quit)                                                                                                                                                                                                                                                                                
Session Status                online                                                                                                                                                                                                                                            
Account                       Ashish Tiwari (Plan: Free)                                                                                                                                                                                                                        
Version                       2.3.25                                                                                                                                                                                                                                            
Region                        United States (us)                                                                                                                                                                                                                                
Web Interface                                                                                                                                                                                                                                    
Forwarding                    http://b6ad4280.ngrok.io -> http://localhost:5000                                                                                                                                                                                                 
Forwarding                    https://b6ad4280.ngrok.io -> http://localhost:5000                                                                                                                                                                                                
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                                                                                       
                              0       0       0.00    0.00    0.00    0.00         

App is running on http://b6ad4280.ngrok.io


Post a Comment