Created
August 14, 2020 21:07
-
-
Save tachyondecay/39d4990bedd894baf34ee0594ebc1d3d to your computer and use it in GitHub Desktop.
Host matching with Flask
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
def create_app(): | |
"""Factory for the application.""" | |
config_name = os.getenv('FLASK_ENV', 'production') | |
app = Flask( | |
'lemonade_soapbox', | |
static_folder='assets', | |
static_host=os.getenv('MAIN_HOST'), | |
host_matching=True, | |
) | |
# Lots of standard app setup things here | |
from lemonade_soapbox.views import admin, api, blog, frontend, reviews | |
# Register admin and API blueprints on both domains so we can log in to both | |
app.register_blueprint(admin.bp, host=os.getenv('MAIN_HOST'), url_prefix='/meta') | |
app.register_blueprint(api.bp, host=os.getenv('MAIN_HOST'), url_prefix='/api') | |
app.register_blueprint(blog.bp, host=os.getenv('MAIN_HOST'), url_prefix='/blog') | |
app.register_blueprint(frontend.bp, host=os.getenv('MAIN_HOST'), url_prefix='/') | |
app.register_blueprint(admin.bp, host=os.getenv('REVIEW_HOST'), url_prefix='/meta') | |
app.register_blueprint(api.bp, host=os.getenv('REVIEW_HOST'), url_prefix='/api') | |
app.register_blueprint(reviews.bp, host=os.getenv('REVIEW_HOST'), url_prefix='/') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment