Created
October 31, 2012 11:36
-
-
Save maximebf/3986583 to your computer and use it in GitHub Desktop.
Add dynamic subdomain support to a Flask app
This file contains hidden or 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 add_subdomain_to_global(endpoint, values): | |
g.subdomain = values.pop('subdomain', None) | |
def add_subdomain_to_url_params(endpoint, values): | |
if not 'subdomain' in values: | |
values['subdomain'] = g.subdomain | |
def add_subdomain_support(app): | |
app.url_value_preprocessor(add_subdomain_to_global) | |
app.url_defaults(add_subdomain_to_url_params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment