[how] Publish FLASK Web App On COLAB Via NGROK

 



(1) Install NGROK

!pip install pyngrok

(2) Add Authtoken

Get token from NGROK: 

https://dashboard.ngrok.com/get-started/your-authtoken

Add token to COLAB: 

!ngrok authtoken XXXXXXDLBJs4NIhxfACRilHJHSN_oymwXVGVMdPkvpKYYYYY


(3) Install FLASK-NGROK

!pip install flask-ngrok


(4) Write and Publish Flask Web App

from flask import Flask
from flask_ngrok import run_with_ngrok
app = Flask(__name__)
run_with_ngrok(app)   
  
@app.route("/")
def home():
    return "<h1>Hello World</h1>"

@app.route('/user/<id>')
def get_user(id):
 user = id
 return '<h1>Hello, {}</h1>'.format(user)


app.run()






Post a Comment

0 Comments