Last active
May 8, 2023 08:40
-
-
Save ManivannanMurugavel/98cb2dec7b9cdf4a89a6e7015d5b1214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "flask-colab.ipynb", | |
"provenance": [] | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "_dPNjwSC_vaI", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# **Install Required python library**" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "1RLgb7uF_Cod", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 119 | |
}, | |
"outputId": "0d036503-95ce-4069-b5e2-a290ccc4e931" | |
}, | |
"source": [ | |
"!pip install flask" | |
], | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Requirement already satisfied: flask in /usr/local/lib/python3.6/dist-packages (1.1.2)\n", | |
"Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python3.6/dist-packages (from flask) (2.11.2)\n", | |
"Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.6/dist-packages (from flask) (7.1.2)\n", | |
"Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python3.6/dist-packages (from flask) (1.0.1)\n", | |
"Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python3.6/dist-packages (from flask) (1.1.0)\n", | |
"Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from Jinja2>=2.10.1->flask) (1.1.1)\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "_LBX_JyBABzG", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# **Import Library**" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "DtpR6O_l_ogB", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"import flask\n", | |
"from IPython import get_ipython" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "PXbqEmLnAw7E", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# **Download ngrok and extract it**" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "U5JI0GVHAuVZ", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 238 | |
}, | |
"outputId": "1fe389b7-990c-4519-f707-36ce01751f23" | |
}, | |
"source": [ | |
"!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n", | |
"!unzip -o ngrok-stable-linux-amd64.zip" | |
], | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"--2020-05-27 07:23:16-- https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n", | |
"Resolving bin.equinox.io (bin.equinox.io)... 34.193.189.199, 52.204.235.107, 34.205.198.58, ...\n", | |
"Connecting to bin.equinox.io (bin.equinox.io)|34.193.189.199|:443... connected.\n", | |
"HTTP request sent, awaiting response... 200 OK\n", | |
"Length: 13773305 (13M) [application/octet-stream]\n", | |
"Saving to: ‘ngrok-stable-linux-amd64.zip’\n", | |
"\n", | |
"\r ngrok-sta 0%[ ] 0 --.-KB/s \r ngrok-stab 0%[ ] 102.18K 400KB/s \r ngrok-stabl 6%[> ] 886.98K 1.70MB/s \r ngrok-stable 46%[========> ] 6.14M 8.02MB/s \rngrok-stable-linux- 100%[===================>] 13.13M 13.9MB/s in 0.9s \n", | |
"\n", | |
"2020-05-27 07:23:17 (13.9 MB/s) - ‘ngrok-stable-linux-amd64.zip’ saved [13773305/13773305]\n", | |
"\n", | |
"Archive: ngrok-stable-linux-amd64.zip\n", | |
" inflating: ngrok \n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "r6_nu6nUA8L8", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# **Run the services**" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "MjrLWlOjBO7e", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"get_ipython().system_raw('python app.py &')" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "LubrQoemBQip", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"get_ipython().system_raw('./ngrok http 5000 &')" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "KUjcWgFKBWtn", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# **Show the ngrok tunnel IP**" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "IVG-gFZZBaRk", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
}, | |
"outputId": "8624336a-093a-45bc-99bc-1bdfcd6c1a66" | |
}, | |
"source": [ | |
"! curl -s http://localhost:4040/api/tunnels | python3 -c \\\n", | |
" \"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])\"" | |
], | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"http://353fbfa7.ngrok.io\n" | |
], | |
"name": "stdout" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment