Fix 0 port value being overriden by default

By explicitly comparing port value with None,
instead of using its bool() value.
This commit is contained in:
vorelq 2018-09-29 18:38:32 +02:00 committed by David Lord
parent 05102f63b8
commit e1cc16f8be
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 14 additions and 8 deletions

View file

@ -972,7 +972,8 @@ class Flask(_PackageBoundObject):
sn_host, _, sn_port = server_name.partition(":")
host = host or sn_host or _host
port = int(port or sn_port or _port)
# pick the first value that's not None (0 is allowed)
port = int(next((p for p in (port, sn_port) if p is not None), _port))
options.setdefault("use_reloader", self.debug)
options.setdefault("use_debugger", self.debug)