Last active
February 19, 2021 15:30
-
-
Save carc1n0gen/2115eab3b263390405303c3ae36ec22b to your computer and use it in GitHub Desktop.
Flask Blueprint Subdomains
This file contains 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
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