title: How set the host and the port of a Flask app in config module?
body: <p>To execute an application in Flask we use the method</p>
  
  <pre><code>app.run ()
  </code></pre>
  
  <p>In this method we can pass configuration parameters, among them:</p>
  
  <pre><code>host, port, debug
  </code></pre>
  
  <p>By default the Flask application is executed in</p>
  
  <pre><code>host = localhost
  port = 5000
  </code></pre>
  
  <p>So, if we want to change that configuration, we pass it to the run method</p>
  
  <pre><code>app.run (host = "10.100.100.10", port = 9566)
  </code></pre>
  
  <p>In the case of wanting to have different configurations for your application (either, production, development, testing) you must define a configuration dictionary, something like this:</p>
  
  <pre><code>app.config.update (
      DEBUG = True,
      SECRET_KEY = '...'
  )
  </code></pre>
  
  <p>Or more specified create a config module:</p>
  
  <pre><code>class Base(object):
      DEBUG = False
      SECRET_KEY = "Shhhh is a secret"
      SERVER_NAME="localhost:5000"
  
  class Develop(Base):
      SERVER_NAME="10.100.100.10:5001"
  </code></pre>
  
  <p>Reading (<a href="http://flask.pocoo.org/docs/0.12/config/" rel="noreferrer">http://flask.pocoo.org/docs/0.12/config/</a>) I found this attribute:</p>
  
  <pre><code>SERVER_NAME
  </code></pre>
  
  <p>Quoting the Flask documentation:</p>
  
  <blockquote>
    <p>the name and port number of the server. Required for subdomain support
    (e.g .: 'myapp.dev:5000') Note that localhost does not support
    subdomains so setting this to "localhost" does not help. Setting to
    SERVER_NAME also by default enables URL generation without a request
    context but with an application context.</p>
  </blockquote>
  
  <p>This attribute should change the host and the port.</p>
  
  <p>I defined this then:</p>
  
  <pre><code>app.config.update (
      DEBUG = True,
      SERVER_NAME = "10.100.100.10:6500"
  )
  
  and
  
  class Base(object):
      DEBUG = False
      SECRET_KEY = "Shhhh is a secret"
      SERVER_NAME="localhost:5000"
  
  class Develop(Base):
      SERVER_NAME="10.100.100.10:5001"
  
  and
  
  app = Flask(__name__)
  
  app.config.from_object('config.Develop')
  </code></pre>
  
  <p>As a result it keeps showing when executing the application:</p>
  
  <pre><code>Running in 127.0.0.1:5000
  </code></pre>
  
  <p><strong>How can I make my application run on another host and port without having to use parameters in the run method?</strong></p>