A simple way to demo Flask apps from your machine.

Related tags

Flask flask-ngrok
Overview

flask-ngrok

Run it button

PyPI version

A simple way to demo Flask apps from your machine. Makes your Flask apps running on localhost available over the internet via the excellent ngrok tool.

Compatability

Python 3.6+ is required.

Installation

pip install flask-ngrok

Inside Jupyter / Colab Notebooks

Notebooks have an issue with newer versions of Flask, so force an older version if working in these environments.

!pip install flask==0.12.2

See the example notebook for a working example.

Quickstart

  1. Import with from flask_ngrok import run_with_ngrok
  2. Add run_with_ngrok(app) to make your Flask app available upon running
# flask_ngrok_example.py
from flask import Flask
from flask_ngrok import run_with_ngrok

app = Flask(__name__)
run_with_ngrok(app)  # Start ngrok when app is run

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == '__main__':
    app.run()

Running the example:

python flask_ngrok_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 
Comments
  • Virtualenv support

    Virtualenv support

    I use flask inside a virtualenv (on a Linux machine) which causes the library to fail as it won't have the permission to write to /tmp/ngrok/ngrok.

    Potentially could you save it in the virtualenv?

    opened by VikashKothary 11
  • Cannot use flask-ngrok over Colab

    Cannot use flask-ngrok over Colab

    Model loaded. Start serving...

    Exception in thread Thread-5: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 1182, in run self.function(*self.args, **self.kwargs) File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 70, in start_ngrok ngrok_address = _run_ngrok() File "/usr/local/lib/python3.6/dist-packages/flask_ngrok.py", line 38, in _run_ngrok tunnel_url = j['tunnels'][0]['public_url'] # Do the parsing of the get IndexError: list index out of range

    This is the traceback.

    opened by knightowl2704 4
  • Incorrect chmod call

    Incorrect chmod call

    Hi,

    The permission to the ngrok download file are not correctly setup under Python 3.7. I solved this by modifiying line 29 of flask_ngrok.py with: os.chmod(executable, 777) to os.chmod(executable, 0o777) Sorry if I am not following the standard process for patching, I am not a developper.

    Also a side not it would be good if flask-ngrok carry the kwargs arguments to the call of app.run.

    opened by aerospeace 1
  • Mac can't use flask ngrok

    Mac can't use flask ngrok

    have some error code I can't fix it Use a production WSGI server instead.

    • Debug mode: off
    • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) Exception in thread Thread-7: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 1177, in run self.function(*self.args, **self.kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_ngrok.py", line 70, in start_ngrok ngrok_address = _run_ngrok() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_ngrok.py", line 31, in _run_ngrok ngrok = subprocess.Popen([executable, 'http', '5000']) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 800, in init restore_signals, start_new_session) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1551, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: '/var/folders/0v/yyx5g7sj7gq8k1lq4ys8g1r80000gn/T/ngrok/ngrok'
    opened by CowBae7777 0
  • Flask run parameters

    Flask run parameters

    As you are replacing the current run function, you break any existing functionality that relies on passing in parameters. Maybe you can pass them through your function into the old function?

    opened by VikashKothary 0
  • Incompatible with socketio

    Incompatible with socketio

    When attempting to write a simple flask websocket app with socketio, adding this package produces TypeError: new_run() got an unexpected keyword argument 'host'

    opened by aydanjiwani 0
  • Some fixes and additions making it suitable for Flask 2.1.2

    Some fixes and additions making it suitable for Flask 2.1.2

    Add an option to set an auto-token and the ngrok download link is being generated from the ngrok download webpage automatically Can you check it out please

    opened by EthanA120 0
  • Support for ARM architecture devices

    Support for ARM architecture devices

    A fix for #29

    The platform.system()output for the Raspberry Pi OS is also 'Linux'. https://github.com/gstaff/flask-ngrok/blob/33a2e70898c4fb72b645715dacd8789769a99350/flask_ngrok.py#L50

    This leads to a download of the wrong ngrok executable for ARM devices.

    Added an additional if else statement in line #55 flask_ngrok.py

    elif system == "Linux":
            if 'arm' in os.uname().machine and platform.architecture()[0] == '64bit':
                url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.zip"
            elif 'arm' in os.uname().machine and platform.architecture()[0] == '32bit':
                url="https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip"
            else:
                url = "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
    
    opened by srividya-p 4
  • Stuck on this: OSError: [Errno 8] Exec format error: '/tmp/ngrok/ngrok'

    Stuck on this: OSError: [Errno 8] Exec format error: '/tmp/ngrok/ngrok'

    Any idea why I'm getting this error with a basic test script? i'm running the script as: sudo python3 flaskngrokdemo.py

    raspberry pi zero (not 64bit, maybe the problem?)

    Name: flask-ngrok Version: 0.0.26 Summary: A simple way to demo Flask apps from your machine. Home-page: https://github.com/gstaff/flask-ngrok Author: Grant Stafford Author-email: None License: UNKNOWN Location: /home/pi/.local/lib/python3.7/site-packages Requires: Flask, requests Required-by:

    Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 1166, in run self.function(*self.args, **self.kwargs) File "/usr/local/lib/python3.7/dist-packages/flask_ngrok.py", line 70, in start_ngrok ngrok_address = _run_ngrok() File "/usr/local/lib/python3.7/dist-packages/flask_ngrok.py", line 31, in _run_ngrok ngrok = subprocess.Popen([executable, 'http', '5000']) File "/usr/lib/python3.7/subprocess.py", line 775, in init restore_signals, start_new_session) File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/tmp/ngrok/ngrok'

    opened by snarflakes 1
  • Colab: Unable to access webpage using flask-ngrok

    Colab: Unable to access webpage using flask-ngrok

    I'm trying to run flask application on colab but I keep seeing the following when I go to the tunneled page:-

    image

    Code:-

    # flask_ngrok_example.py
    from flask import Flask
    from flask_ngrok import run_with_ngrok
    
    app = Flask(__name__)
    run_with_ngrok(app)  # Start ngrok when app is run
    
    @app.route("/")
    def hello():
        return "Hello World!"
    
    if __name__ == '__main__':
        app.run()
    
    opened by krypticmouse 2
Owner
null
Boilerplate code for basic flask web apps

Flask Boilerplate This repository contains boilerplate code to start a project instantly It's mainly for projects which you plan to ship in less than

Abhishek 6 Sep 27, 2021
Lux Academy & Data Science East Africa Python Boot Camp, Building and Deploying Flask Application Using Docker Demo App.

Flask and Docker Application Demo A Docker image is a read-only, inert template that comes with instructions for deploying containers. In Docker, ever

Harun Mbaabu Mwenda 11 Oct 29, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 310 Dec 14, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 282 Feb 11, 2021
Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development.

Flask-Starter Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development. It has all the r

Kundan Singh 259 Dec 26, 2022
Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python

Flask-Discord-Bot-Dashboard A simple discord Bot dashboard created in Flask Pyth

Ethan 8 Dec 22, 2022
Flask-template - A simple template for make an flask api

flask-template By GaGoU :3 a simple template for make an flask api notes: you ca

GaGoU 2 Feb 17, 2022
A simple demo of using aiogram + async sqlalchemy 1.4+

aiogram-and-sqlalchemy-demo A simple demo of using aiogram + async sqlalchemy 1.4+ Used tech: aiogram SQLAlchemy 1.4+ PostgreSQL as database asyncpg a

Aleksandr 68 Dec 31, 2022
Seamlessly serve your static assets of your Flask app from Amazon S3

flask-s3 Seamlessly serve the static assets of your Flask app from Amazon S3. Maintainers Flask-S3 is maintained by @e-dard, @eriktaubeneck and @SunDw

Edd Robinson 188 Aug 24, 2022
Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.

Flask-Rebar Flask-Rebar combines flask, marshmallow, and swagger for robust REST services. Features Request and Response Validation - Flask-Rebar reli

PlanGrid 223 Dec 19, 2022
Brandnew-flask is a CLI tool used to generate a powerful and mordern flask-app that supports the production environment.

Brandnew-flask is still in the initial stage and needs to be updated and improved continuously. Everyone is welcome to maintain and improve this CLI.

brandonye 4 Jul 17, 2022
Flask Project Template A full feature Flask project template.

Flask Project Template A full feature Flask project template. See also Python-Project-Template for a lean, low dependency Python app. HOW TO USE THIS

Bruno Rocha 96 Dec 23, 2022
A Fast API style support for Flask. Gives you MyPy types with the flexibility of flask

Flask-Fastx Flask-Fastx is a Fast API style support for Flask. It Gives you MyPy types with the flexibility of flask. Compatibility Flask-Fastx requir

Tactful.ai 18 Nov 26, 2022
Flask-app scaffold, generate flask restful backend

Flask-app scaffold, generate flask restful backend

jacksmile 1 Nov 24, 2021
Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure.

Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure. All the required libraries are already installed easily to use in any big project.

Ajay kumar sharma 5 Jun 14, 2022
flask-reactize is a boostrap to serve any React JS application via a Python back-end, using Flask as web framework.

flask-reactize Purpose Developing a ReactJS application requires to use nodejs as back end server. What if you want to consume external APIs: how are

Julien Chomarat 4 Jan 11, 2022
Pf-flask-rest-com - Flask REST API Common Implementation by Problem Fighter Library

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Rest-Com Docu

Problem Fighter 3 Jan 15, 2022
Open-source Flask Sample built on top of flask-dance library

Open-source Flask Sample built on top of flask-dance library. The project implements the social login for Github and Twitter - Originally coded by TestDriven.IO.

App Generator 4 Jul 26, 2022
Flask-redmail - Email sending for Flask

Flask Red Mail: Email Sending for Flask Flask extension for Red Mail What is it?

Mikael Koli 11 Sep 23, 2022