Wednesday, April 17, 2019

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

Edit file

from flask import Flask
app = Flask(__name__)

def hello():
    return "Hello World!"

if __name__ == '__main__':

Run Flask app and visit localhost:5000


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

./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://localhost:5000                                                                                                                                                                                                 
Forwarding           -> http://localhost:5000                                                                                                                                                                                                
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                                                                                       
                              0       0       0.00    0.00    0.00    0.00         

App is running on