Skip to content

Instantly share code, notes, and snippets.

@maximebf
Created October 31, 2012 11:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save maximebf/3986583 to your computer and use it in GitHub Desktop.
Save maximebf/3986583 to your computer and use it in GitHub Desktop.
Add dynamic subdomain support to a Flask app
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