# flask-ngrok3
[](https://colab.research.google.com/github/Partycode/flask-ngrok3/blob/master/examples/flask_ngrok3_example.ipynb)
[](https://badge.fury.io/py/flask-ngrok3)
The successor for [flask-ngrok](https://github.com/gstaff/flask-ngrok) and [flask-ngrok2](https://github.com/MohamedAliRashad/flask-ngrok2) for making demo Flask apps from personal machine.
## Compatability
Python 3.6+ is required.
## Installation
```bash
pip install flask-ngrok3
```
### Inside Jupyter / Colab Notebooks
Notebooks have [an issue](https://stackoverflow.com/questions/51180917/python-flask-unsupportedoperation-not-writable) with newer versions of Flask, so force an older version if working in these environments.
```bash
!pip install flask==0.12.2
```
See the [example notebook](https://colab.research.google.com/github/Partycode/flask-ngrok3/blob/master/examples/flask_ngrok3_example.ipynb) for a working example.
## Quickstart
1. Import with ```from flask_ngrok3 import run_with_ngrok```
2. Add `run_with_ngrok(app)` to make your Flask app available upon running
3. Now you can run with your custom host `app.run(host='192.168.1.5')`
4. Also, you can get ngrok address on startup
```python
# flask_ngrok3_example.py
from flask import Flask
from flask_ngrok3 import run_with_ngrok, get_host
app = Flask(__name__)
run_with_ngrok(app) # Start ngrok when app is run
@app.route("/")
def hello():
return "Hello World!"
def get_ngrok_host():
print(f"ngrok host is: {get_host()}")
app.before_first_request(get_ngrok_host) # Register function for run before the first request
if __name__ == '__main__':
app.run()
```
Running the example:
```bash
python flask_ngrok3_example.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Running on http://<random-address>.ngrok.io
* Traffic stats available on http://127.0.0.1:4040
ngrok host is: http://<random-address>.ngrok.io
127.0.0.1 - - [...] "GET / HTTP/1.1" 200 -
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Partycode/flask-ngrok3",
"name": "flask-ngrok3",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "flask ngrok demo",
"author": "Partycode",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/91/20/08aa9db2a5f45a0ea5651aec96c1bfe83378528fb57aa5fd70c8e9cc11c7/flask-ngrok3-0.3.1.tar.gz",
"platform": null,
"description": "# flask-ngrok3\n[](https://colab.research.google.com/github/Partycode/flask-ngrok3/blob/master/examples/flask_ngrok3_example.ipynb)\n\n[](https://badge.fury.io/py/flask-ngrok3)\n\nThe successor for [flask-ngrok](https://github.com/gstaff/flask-ngrok) and [flask-ngrok2](https://github.com/MohamedAliRashad/flask-ngrok2) for making demo Flask apps from personal machine.\n\n## Compatability\nPython 3.6+ is required.\n\n## Installation\n\n```bash\npip install flask-ngrok3\n```\n### Inside Jupyter / Colab Notebooks\nNotebooks have [an issue](https://stackoverflow.com/questions/51180917/python-flask-unsupportedoperation-not-writable) with newer versions of Flask, so force an older version if working in these environments.\n```bash\n!pip install flask==0.12.2\n```\nSee the [example notebook](https://colab.research.google.com/github/Partycode/flask-ngrok3/blob/master/examples/flask_ngrok3_example.ipynb) for a working example.\n\n## Quickstart\n1. Import with ```from flask_ngrok3 import run_with_ngrok```\n2. Add `run_with_ngrok(app)` to make your Flask app available upon running\n3. Now you can run with your custom host `app.run(host='192.168.1.5')`\n4. Also, you can get ngrok address on startup \n```python\n# flask_ngrok3_example.py\nfrom flask import Flask\nfrom flask_ngrok3 import run_with_ngrok, get_host\n\napp = Flask(__name__)\nrun_with_ngrok(app) # Start ngrok when app is run\n\n@app.route(\"/\")\ndef hello():\n return \"Hello World!\"\n\ndef get_ngrok_host():\n print(f\"ngrok host is: {get_host()}\")\n\napp.before_first_request(get_ngrok_host) # Register function for run before the first request\n\nif __name__ == '__main__':\n app.run()\n```\n\nRunning the example:\n```bash\npython flask_ngrok3_example.py\n * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n * Running on http://<random-address>.ngrok.io\n * Traffic stats available on http://127.0.0.1:4040 \nngrok host is: http://<random-address>.ngrok.io\n127.0.0.1 - - [...] \"GET / HTTP/1.1\" 200 -\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "A successor to flask-ngrok and flask-ngrok2 for demo Flask apps using ngrok.",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/Partycode/flask-ngrok3"
},
"split_keywords": [
"flask",
"ngrok",
"demo"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4acabf90ca354b0383d1ddc30645d5c1ec6c088c8fdeb1476b5764209f81aa18",
"md5": "b5573be1074294ecbabfe42d647ec3b4",
"sha256": "ab0bca39529bc7151b81b01c036d1ec3abcb7be94d29a8bddfa9ebd8694575c3"
},
"downloads": -1,
"filename": "flask_ngrok3-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b5573be1074294ecbabfe42d647ec3b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6223,
"upload_time": "2023-05-07T18:37:55",
"upload_time_iso_8601": "2023-05-07T18:37:55.901719Z",
"url": "https://files.pythonhosted.org/packages/4a/ca/bf90ca354b0383d1ddc30645d5c1ec6c088c8fdeb1476b5764209f81aa18/flask_ngrok3-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "912008aa9db2a5f45a0ea5651aec96c1bfe83378528fb57aa5fd70c8e9cc11c7",
"md5": "2f307b467d30968c134b92799ee079a4",
"sha256": "2d7e95127af78b73c6bcea230da222702ca1458c2fe14c14c7b3c8574ee62d9c"
},
"downloads": -1,
"filename": "flask-ngrok3-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "2f307b467d30968c134b92799ee079a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5997,
"upload_time": "2023-05-07T18:37:57",
"upload_time_iso_8601": "2023-05-07T18:37:57.585667Z",
"url": "https://files.pythonhosted.org/packages/91/20/08aa9db2a5f45a0ea5651aec96c1bfe83378528fb57aa5fd70c8e9cc11c7/flask-ngrok3-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-07 18:37:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Partycode",
"github_project": "flask-ngrok3",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flask-ngrok3"
}