Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Forked from dunossauro/app_1.py
Last active April 10, 2020 15:59
Show Gist options
  • Save rochacbruno/e44c1f0f43e89093bf7ddba77ee9feef to your computer and use it in GitHub Desktop.
Save rochacbruno/e44c1f0f43e89093bf7ddba77ee9feef to your computer and use it in GitHub Desktop.
Flask merge route example
$ pip3 install flask
$ export FLASK_APP=manage.py

$ flask routes
$ flask run
$ flask shell
$ flask routes

Endpoint        Methods  Rule
--------------  -------  -----------------------
bp1.get_route1  GET      /api/v1/test_route1
bp2.get_route2  GET      /api/v1/test_route2
static          GET      /static/<path:filename>
from flask import Blueprint
bp = Blueprint("bp1", __name__)
@bp.route('/api/v1/test_route1')
def get_route1():
return '42'
from flask import Blueprint
bp = Blueprint("bp2", __name__)
@bp.route('/api/v1/test_route2')
def get_route2():
return '42'
import app_1
import app_2
from flask import Flask
app = Flask(__name__)
app.register_blueprint(app_1.bp)
app.register_blueprint(app_2.bp)
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment