|
|
|
@ -123,8 +123,13 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
.. versionadded:: 0.11 |
|
|
|
|
The `root_path` parameter was added. |
|
|
|
|
|
|
|
|
|
.. versionadded:: 0.13 |
|
|
|
|
The `host_matching` and `static_host` parameters were added. |
|
|
|
|
.. versionadded:: 1.0 |
|
|
|
|
The ``host_matching`` and ``static_host`` parameters were added. |
|
|
|
|
|
|
|
|
|
.. versionadded:: 1.0 |
|
|
|
|
The ``subdomain_matching`` parameter was added. Subdomain |
|
|
|
|
matching needs to be enabled manually now. Setting |
|
|
|
|
:data:`SERVER_NAME` does not implicitly enable it. |
|
|
|
|
|
|
|
|
|
:param import_name: the name of the application package |
|
|
|
|
:param static_url_path: can be used to specify a different path for the |
|
|
|
@ -133,11 +138,13 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
:param static_folder: the folder with static files that should be served |
|
|
|
|
at `static_url_path`. Defaults to the ``'static'`` |
|
|
|
|
folder in the root path of the application. |
|
|
|
|
:param host_matching: sets the app's ``url_map.host_matching`` to the given |
|
|
|
|
value. Defaults to False. |
|
|
|
|
:param static_host: the host to use when adding the static route. Defaults |
|
|
|
|
to None. Required when using ``host_matching=True`` |
|
|
|
|
:param static_host: the host to use when adding the static route. |
|
|
|
|
Defaults to None. Required when using ``host_matching=True`` |
|
|
|
|
with a ``static_folder`` configured. |
|
|
|
|
:param host_matching: set ``url_map.host_matching`` attribute. |
|
|
|
|
Defaults to False. |
|
|
|
|
:param subdomain_matching: consider the subdomain relative to |
|
|
|
|
:data:`SERVER_NAME` when matching routes. Defaults to False. |
|
|
|
|
:param template_folder: the folder that contains the templates that should |
|
|
|
|
be used by the application. Defaults to |
|
|
|
|
``'templates'`` folder in the root path of the |
|
|
|
@ -347,6 +354,7 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
static_folder='static', |
|
|
|
|
static_host=None, |
|
|
|
|
host_matching=False, |
|
|
|
|
subdomain_matching=False, |
|
|
|
|
template_folder='templates', |
|
|
|
|
instance_path=None, |
|
|
|
|
instance_relative_config=False, |
|
|
|
@ -530,6 +538,7 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
self.url_map = Map() |
|
|
|
|
|
|
|
|
|
self.url_map.host_matching = host_matching |
|
|
|
|
self.subdomain_matching = subdomain_matching |
|
|
|
|
|
|
|
|
|
# tracks internally if the application already handled at least one |
|
|
|
|
# request. |
|
|
|
@ -1978,18 +1987,29 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
|
|
|
|
|
def create_url_adapter(self, request): |
|
|
|
|
"""Creates a URL adapter for the given request. The URL adapter |
|
|
|
|
is created at a point where the request context is not yet set up |
|
|
|
|
so the request is passed explicitly. |
|
|
|
|
is created at a point where the request context is not yet set |
|
|
|
|
up so the request is passed explicitly. |
|
|
|
|
|
|
|
|
|
.. versionadded:: 0.6 |
|
|
|
|
|
|
|
|
|
.. versionchanged:: 0.9 |
|
|
|
|
This can now also be called without a request object when the |
|
|
|
|
URL adapter is created for the application context. |
|
|
|
|
|
|
|
|
|
.. versionchanged:: 1.0 |
|
|
|
|
:data:`SERVER_NAME` no longer implicitly enables subdomain |
|
|
|
|
matching. Use :attr:`subdomain_matching` instead. |
|
|
|
|
""" |
|
|
|
|
if request is not None: |
|
|
|
|
return self.url_map.bind_to_environ(request.environ, |
|
|
|
|
server_name=self.config['SERVER_NAME']) |
|
|
|
|
# If subdomain matching is disabled (the default), use the |
|
|
|
|
# default subdomain in all cases. This should be the default |
|
|
|
|
# in Werkzeug but it currently does not have that feature. |
|
|
|
|
subdomain = ((self.url_map.default_subdomain or None) |
|
|
|
|
if not self.subdomain_matching else None) |
|
|
|
|
return self.url_map.bind_to_environ( |
|
|
|
|
request.environ, |
|
|
|
|
server_name=self.config['SERVER_NAME'], |
|
|
|
|
subdomain=subdomain) |
|
|
|
|
# We need at the very least the server name to be set for this |
|
|
|
|
# to work. |
|
|
|
|
if self.config['SERVER_NAME'] is not None: |
|
|
|
|