Skip to content

Instantly share code, notes, and snippets.

@carc1n0gen
Last active February 19, 2021 15:30
Show Gist options
  • Save carc1n0gen/2115eab3b263390405303c3ae36ec22b to your computer and use it in GitHub Desktop.
Save carc1n0gen/2115eab3b263390405303c3ae36ec22b to your computer and use it in GitHub Desktop.
Flask Blueprint Subdomains
from flask import Flask, Blueprint, url_for
app = Flask(__name__)
app.config['SERVER_NAME'] = 'app.local:5000'
bp1 = Blueprint('bp1', __name__, subdomain='app1')
bp2 = Blueprint('bp2', __name__, subdomain='app2')
@bp1.route('/')
def home1():
app.logger.info('bp1.home1')
return url_for('bp1.home1')
@bp2.route('/')
def home2():
app.logger.info('bp2.home2')
return url_for('bp2.home2')
app.register_blueprint(bp1)
app.register_blueprint(bp2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment