Browse Source

The default run method is now accepting the port from the SERVER_NAME.

pull/764/head
Armin Ronacher 12 years ago
parent
commit
62dbe0e1ca
  1. 2
      CHANGES
  2. 13
      flask/app.py

2
CHANGES

@ -71,6 +71,8 @@ Release date to be decided.
- Flask now orders JSON keys by default to not trash HTTP caches due to - Flask now orders JSON keys by default to not trash HTTP caches due to
different hash seeds between different workers. different hash seeds between different workers.
- Added `appcontext_pushed` and `appcontext_popped` signals. - Added `appcontext_pushed` and `appcontext_popped` signals.
- The builtin run method now takes the ``SERVER_NAME`` into account when
picking the default port to run on.
Version 0.9 Version 0.9
----------- -----------

13
flask/app.py

@ -739,10 +739,15 @@ class Flask(_PackageBoundObject):
won't catch any exceptions because there won't be any to won't catch any exceptions because there won't be any to
catch. catch.
.. versionchanged:: 0.10
The default port is now picked from the ``SEVER_NAME`` variable.
:param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
have the server available externally as well. Defaults to have the server available externally as well. Defaults to
``'127.0.0.1'``. ``'127.0.0.1'``.
:param port: the port of the webserver. Defaults to ``5000``. :param port: the port of the webserver. Defaults to ``5000`` or the
port defined in the ``SERVER_NAME`` config variable if
present.
:param debug: if given, enable or disable debug mode. :param debug: if given, enable or disable debug mode.
See :attr:`debug`. See :attr:`debug`.
:param options: the options to be forwarded to the underlying :param options: the options to be forwarded to the underlying
@ -754,7 +759,11 @@ class Flask(_PackageBoundObject):
if host is None: if host is None:
host = '127.0.0.1' host = '127.0.0.1'
if port is None: if port is None:
port = 5000 server_name = self.config['SERVER_NAME']
if server_name and ':' in server_name:
port = int(server_name.rsplit(':', 1)[1])
else:
port = 5000
if debug is not None: if debug is not None:
self.debug = bool(debug) self.debug = bool(debug)
options.setdefault('use_reloader', self.debug) options.setdefault('use_reloader', self.debug)

Loading…
Cancel
Save