Based on flask-ngrok and flask-ngrok2 The successor for flask-ngrok for making demo Flask apps from personal machine with added auth token functionality to build indipendent full stack apps within jupyer notebook and google collab. notebooks.
Python 3.6+ is required.
pip install git+https://github.com/Davz33/flask-ngrok2-pageprinter
- Import with
from flask_ngrok2_pp import run_with_ngrok
- Add
run_with_ngrok(app,logpath,auth_token)
to make your Flask app available upon running - At server start, the log at logpath will contain the ngrok tunnel address. You can then json.load-it and make use of it for http/https request within jupyter notebooks.
To make full sense of this package, you need to run the following as python command from a .py external script:
If you want to self-contain every piece of your notebook, just !touch script.py
and write into from your j.notebook cell.
# flask_ngrok_example.py
from flask import Flask
from flask_ngrok2_pp import run_with_ngrok
app = Flask(__name__)
run_with_ngrok(app, logpath=LOGPATH, auth_token=authtoken) # Start ngrok when app is run
@app.route("/")
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
Then, in your jupyer notebook, you can use json.load()
to pull the active tunnel address.