a.example.com b.example.com I want to put in in flask with the same application folder,diferrent config files. I found the following solution,but how to use them?
Create a context processor that injects 'request.host' into your templates and branch accordingly.
For more control, you could create a Site object, instantiated from the current request, and add properties to that, for example:
class Site(object):
def __init__(self, request):
self.host = request.host
@cached_property
def google_analytics_id(self, default=''):
if self.host == 'python.example.com':
return <something>
elif self.host == 'apple.example.com':
return <something else>
return default
Then use site = Site(request) in your context processor and refer to site. in your templates. Candidates for other properties might be HTML meta description and keywords, the site's title etc. This kind of branching is only possible from parts of the application that have access to the request object, of course.
Paul