title: Dynamic subdomain in python flask engine
body: <p>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?</p>
  
  <hr>
  
  <p>Create a context processor that injects 'request.host' into your
  templates and branch accordingly.</p>
  
  <p>For more control, you could create a Site object, instantiated from
  the current request, and add properties to that, for example:</p>
  
  <pre><code>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 &lt;something&gt;
      elif self.host == 'apple.example.com':
        return &lt;something else&gt;
      return default
  </code></pre>
  
  <p>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.</p>
  
  <p>Paul</p>