mirror of https://github.com/pallets/flask.git
docs: ``DEBUG``, ``SERVER_NAME``, ``PATH_INFO``
This commit is contained in:
parent
02694d609f
commit
ad011bc32d
12
CHANGES
12
CHANGES
|
@ -339,10 +339,10 @@ Released on June 28th 2011, codename Grappa
|
||||||
1.0 the old behavior will continue to work but issue dependency
|
1.0 the old behavior will continue to work but issue dependency
|
||||||
warnings.
|
warnings.
|
||||||
- fixed a problem for Flask to run on jython.
|
- fixed a problem for Flask to run on jython.
|
||||||
- added a `PROPAGATE_EXCEPTIONS` configuration variable that can be
|
- added a ``PROPAGATE_EXCEPTIONS`` configuration variable that can be
|
||||||
used to flip the setting of exception propagation which previously
|
used to flip the setting of exception propagation which previously
|
||||||
was linked to `DEBUG` alone and is now linked to either `DEBUG` or
|
was linked to ``DEBUG`` alone and is now linked to either ``DEBUG`` or
|
||||||
`TESTING`.
|
``TESTING``.
|
||||||
- Flask no longer internally depends on rules being added through the
|
- Flask no longer internally depends on rules being added through the
|
||||||
`add_url_rule` function and can now also accept regular werkzeug
|
`add_url_rule` function and can now also accept regular werkzeug
|
||||||
rules added to the url map.
|
rules added to the url map.
|
||||||
|
@ -450,7 +450,7 @@ Released on July 6th 2010, codename Calvados
|
||||||
|
|
||||||
- fixed a bug with subdomains that was caused by the inability to
|
- fixed a bug with subdomains that was caused by the inability to
|
||||||
specify the server name. The server name can now be set with
|
specify the server name. The server name can now be set with
|
||||||
the `SERVER_NAME` config key. This key is now also used to set
|
the ``SERVER_NAME`` config key. This key is now also used to set
|
||||||
the session cookie cross-subdomain wide.
|
the session cookie cross-subdomain wide.
|
||||||
- autoescaping is no longer active for all templates. Instead it
|
- autoescaping is no longer active for all templates. Instead it
|
||||||
is only active for ``.html``, ``.htm``, ``.xml`` and ``.xhtml``.
|
is only active for ``.html``, ``.htm``, ``.xml`` and ``.xhtml``.
|
||||||
|
@ -482,8 +482,8 @@ Released on June 18th 2010, codename Rakia
|
||||||
requests that do not pop the request stack for testing.
|
requests that do not pop the request stack for testing.
|
||||||
- because the Python standard library caches loggers, the name of
|
- because the Python standard library caches loggers, the name of
|
||||||
the logger is configurable now to better support unittests.
|
the logger is configurable now to better support unittests.
|
||||||
- added `TESTING` switch that can activate unittesting helpers.
|
- added ``TESTING`` switch that can activate unittesting helpers.
|
||||||
- the logger switches to `DEBUG` mode now if debug is enabled.
|
- the logger switches to ``DEBUG`` mode now if debug is enabled.
|
||||||
|
|
||||||
Version 0.3.1
|
Version 0.3.1
|
||||||
-------------
|
-------------
|
||||||
|
|
|
@ -57,8 +57,8 @@ The following configuration values are used internally by Flask:
|
||||||
``PROPAGATE_EXCEPTIONS`` explicitly enable or disable the
|
``PROPAGATE_EXCEPTIONS`` explicitly enable or disable the
|
||||||
propagation of exceptions. If not set or
|
propagation of exceptions. If not set or
|
||||||
explicitly set to ``None`` this is
|
explicitly set to ``None`` this is
|
||||||
implicitly true if either `TESTING` or
|
implicitly true if either ``TESTING`` or
|
||||||
`DEBUG` is true.
|
``DEBUG`` is true.
|
||||||
``PRESERVE_CONTEXT_ON_EXCEPTION`` By default if the application is in
|
``PRESERVE_CONTEXT_ON_EXCEPTION`` By default if the application is in
|
||||||
debug mode the request context is not
|
debug mode the request context is not
|
||||||
popped on exceptions to enable debuggers
|
popped on exceptions to enable debuggers
|
||||||
|
@ -260,7 +260,7 @@ So a common pattern is this::
|
||||||
|
|
||||||
This first loads the configuration from the
|
This first loads the configuration from the
|
||||||
`yourapplication.default_settings` module and then overrides the values
|
`yourapplication.default_settings` module and then overrides the values
|
||||||
with the contents of the file the :envvar:`YOURAPPLICATION_SETTINGS`
|
with the contents of the file the :envvar:``YOURAPPLICATION_SETTINGS``
|
||||||
environment variable points to. This environment variable can be set on
|
environment variable points to. This environment variable can be set on
|
||||||
Linux or OS X with the export command in the shell before starting the
|
Linux or OS X with the export command in the shell before starting the
|
||||||
server::
|
server::
|
||||||
|
|
|
@ -182,7 +182,7 @@ A basic Flask FastCGI configuration for nginx looks like this::
|
||||||
|
|
||||||
This configuration binds the application to `/yourapplication`. If you
|
This configuration binds the application to `/yourapplication`. If you
|
||||||
want to have it in the URL root it's a bit simpler because you don't
|
want to have it in the URL root it's a bit simpler because you don't
|
||||||
have to figure out how to calculate `PATH_INFO` and `SCRIPT_NAME`::
|
have to figure out how to calculate ``PATH_INFO`` and ``SCRIPT_NAME``::
|
||||||
|
|
||||||
location / { try_files $uri @yourapplication; }
|
location / { try_files $uri @yourapplication; }
|
||||||
location @yourapplication {
|
location @yourapplication {
|
||||||
|
|
|
@ -53,7 +53,7 @@ A basic flask uWSGI configuration for nginx looks like this::
|
||||||
|
|
||||||
This configuration binds the application to `/yourapplication`. If you want
|
This configuration binds the application to `/yourapplication`. If you want
|
||||||
to have it in the URL root it's a bit simpler because you don't have to tell
|
to have it in the URL root it's a bit simpler because you don't have to tell
|
||||||
it the WSGI `SCRIPT_NAME` or set the uwsgi modifier to make use of it::
|
it the WSGI ``SCRIPT_NAME`` or set the uwsgi modifier to make use of it::
|
||||||
|
|
||||||
location / { try_files $uri @yourapplication; }
|
location / { try_files $uri @yourapplication; }
|
||||||
location @yourapplication {
|
location @yourapplication {
|
||||||
|
|
|
@ -74,8 +74,8 @@ Proxy Setups
|
||||||
|
|
||||||
If you deploy your application using one of these servers behind an HTTP proxy
|
If you deploy your application using one of these servers behind an HTTP proxy
|
||||||
you will need to rewrite a few headers in order for the application to work.
|
you will need to rewrite a few headers in order for the application to work.
|
||||||
The two problematic values in the WSGI environment usually are `REMOTE_ADDR`
|
The two problematic values in the WSGI environment usually are ``REMOTE_ADDR``
|
||||||
and `HTTP_HOST`. You can configure your httpd to pass these headers, or you
|
and ``HTTP_HOST``. You can configure your httpd to pass these headers, or you
|
||||||
can fix them in middleware. Werkzeug ships a fixer that will solve some common
|
can fix them in middleware. Werkzeug ships a fixer that will solve some common
|
||||||
setups, but you might want to write your own WSGI middleware for specific
|
setups, but you might want to write your own WSGI middleware for specific
|
||||||
setups.
|
setups.
|
||||||
|
|
|
@ -142,7 +142,7 @@ The Configuration File
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
Now as mentioned above, the application will find the correct
|
Now as mentioned above, the application will find the correct
|
||||||
configuration file by looking up the `YOURAPPLICATION_CONFIG` environment
|
configuration file by looking up the ``YOURAPPLICATION_CONFIG`` environment
|
||||||
variable. So we have to put the configuration in a place where the
|
variable. So we have to put the configuration in a place where the
|
||||||
application will able to find it. Configuration files have the unfriendly
|
application will able to find it. Configuration files have the unfriendly
|
||||||
quality of being different on all computers, so you do not version them
|
quality of being different on all computers, so you do not version them
|
||||||
|
|
|
@ -32,8 +32,8 @@ bootstrapping code for our application::
|
||||||
|
|
||||||
So first we need a couple of imports. Most should be straightforward, the
|
So first we need a couple of imports. Most should be straightforward, the
|
||||||
:func:`werkzeug.secure_filename` is explained a little bit later. The
|
:func:`werkzeug.secure_filename` is explained a little bit later. The
|
||||||
`UPLOAD_FOLDER` is where we will store the uploaded files and the
|
``UPLOAD_FOLDER`` is where we will store the uploaded files and the
|
||||||
`ALLOWED_EXTENSIONS` is the set of allowed file extensions. Then we add a
|
``ALLOWED_EXTENSIONS`` is the set of allowed file extensions. Then we add a
|
||||||
URL rule by hand to the application. Now usually we're not doing that, so
|
URL rule by hand to the application. Now usually we're not doing that, so
|
||||||
why here? The reasons is that we want the webserver (or our development
|
why here? The reasons is that we want the webserver (or our development
|
||||||
server) to serve these files for us and so we only need a rule to generate
|
server) to serve these files for us and so we only need a rule to generate
|
||||||
|
@ -98,7 +98,7 @@ before storing it directly on the filesystem.
|
||||||
filename = "../../../../home/username/.bashrc"
|
filename = "../../../../home/username/.bashrc"
|
||||||
|
|
||||||
Assuming the number of ``../`` is correct and you would join this with
|
Assuming the number of ``../`` is correct and you would join this with
|
||||||
the `UPLOAD_FOLDER` the user might have the ability to modify a file on
|
the ``UPLOAD_FOLDER`` the user might have the ability to modify a file on
|
||||||
the server's filesystem he or she should not modify. This does require some
|
the server's filesystem he or she should not modify. This does require some
|
||||||
knowledge about how the application looks like, but trust me, hackers
|
knowledge about how the application looks like, but trust me, hackers
|
||||||
are patient :)
|
are patient :)
|
||||||
|
|
16
flask/app.py
16
flask/app.py
|
@ -198,7 +198,7 @@ class Flask(_PackageBoundObject):
|
||||||
#: exception occurs and the integrated server will automatically reload
|
#: exception occurs and the integrated server will automatically reload
|
||||||
#: the application if changes in the code are detected.
|
#: the application if changes in the code are detected.
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the `DEBUG`
|
#: This attribute can also be configured from the config with the ``DEBUG``
|
||||||
#: configuration key. Defaults to ``False``.
|
#: configuration key. Defaults to ``False``.
|
||||||
debug = ConfigAttribute('DEBUG')
|
debug = ConfigAttribute('DEBUG')
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class Flask(_PackageBoundObject):
|
||||||
#: default it's implicitly enabled.
|
#: default it's implicitly enabled.
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the
|
#: This attribute can also be configured from the config with the
|
||||||
#: `TESTING` configuration key. Defaults to ``False``.
|
#: ``TESTING`` configuration key. Defaults to ``False``.
|
||||||
testing = ConfigAttribute('TESTING')
|
testing = ConfigAttribute('TESTING')
|
||||||
|
|
||||||
#: If a secret key is set, cryptographic components can use this to
|
#: If a secret key is set, cryptographic components can use this to
|
||||||
|
@ -219,13 +219,13 @@ class Flask(_PackageBoundObject):
|
||||||
#: when you want to use the secure cookie for instance.
|
#: when you want to use the secure cookie for instance.
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the
|
#: This attribute can also be configured from the config with the
|
||||||
#: `SECRET_KEY` configuration key. Defaults to ``None``.
|
#: ``SECRET_KEY`` configuration key. Defaults to ``None``.
|
||||||
secret_key = ConfigAttribute('SECRET_KEY')
|
secret_key = ConfigAttribute('SECRET_KEY')
|
||||||
|
|
||||||
#: The secure cookie uses this for the name of the session cookie.
|
#: The secure cookie uses this for the name of the session cookie.
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the
|
#: This attribute can also be configured from the config with the
|
||||||
#: `SESSION_COOKIE_NAME` configuration key. Defaults to ``'session'``
|
#: ``SESSION_COOKIE_NAME`` configuration key. Defaults to ``'session'``
|
||||||
session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME')
|
session_cookie_name = ConfigAttribute('SESSION_COOKIE_NAME')
|
||||||
|
|
||||||
#: A :class:`~datetime.timedelta` which is used to set the expiration
|
#: A :class:`~datetime.timedelta` which is used to set the expiration
|
||||||
|
@ -233,7 +233,7 @@ class Flask(_PackageBoundObject):
|
||||||
#: permanent session survive for roughly one month.
|
#: permanent session survive for roughly one month.
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the
|
#: This attribute can also be configured from the config with the
|
||||||
#: `PERMANENT_SESSION_LIFETIME` configuration key. Defaults to
|
#: ``PERMANENT_SESSION_LIFETIME`` configuration key. Defaults to
|
||||||
#: ``timedelta(days=31)``
|
#: ``timedelta(days=31)``
|
||||||
permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME',
|
permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME',
|
||||||
get_converter=_make_timedelta)
|
get_converter=_make_timedelta)
|
||||||
|
@ -245,7 +245,7 @@ class Flask(_PackageBoundObject):
|
||||||
#: .. versionadded:: 0.2
|
#: .. versionadded:: 0.2
|
||||||
#:
|
#:
|
||||||
#: This attribute can also be configured from the config with the
|
#: This attribute can also be configured from the config with the
|
||||||
#: `USE_X_SENDFILE` configuration key. Defaults to ``False``.
|
#: ``USE_X_SENDFILE`` configuration key. Defaults to ``False``.
|
||||||
use_x_sendfile = ConfigAttribute('USE_X_SENDFILE')
|
use_x_sendfile = ConfigAttribute('USE_X_SENDFILE')
|
||||||
|
|
||||||
#: The name of the logger to use. By default the logger name is the
|
#: The name of the logger to use. By default the logger name is the
|
||||||
|
@ -560,7 +560,7 @@ class Flask(_PackageBoundObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def propagate_exceptions(self):
|
def propagate_exceptions(self):
|
||||||
"""Returns the value of the `PROPAGATE_EXCEPTIONS` configuration
|
"""Returns the value of the ``PROPAGATE_EXCEPTIONS`` configuration
|
||||||
value in case it's set, otherwise a sensible default is returned.
|
value in case it's set, otherwise a sensible default is returned.
|
||||||
|
|
||||||
.. versionadded:: 0.7
|
.. versionadded:: 0.7
|
||||||
|
@ -572,7 +572,7 @@ class Flask(_PackageBoundObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preserve_context_on_exception(self):
|
def preserve_context_on_exception(self):
|
||||||
"""Returns the value of the `PRESERVE_CONTEXT_ON_EXCEPTION`
|
"""Returns the value of the ``PRESERVE_CONTEXT_ON_EXCEPTION``
|
||||||
configuration value in case it's set, otherwise a sensible default
|
configuration value in case it's set, otherwise a sensible default
|
||||||
is returned.
|
is returned.
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ class RequestContext(object):
|
||||||
for you. In debug mode the request context is kept around if
|
for you. In debug mode the request context is kept around if
|
||||||
exceptions happen so that interactive debuggers have a chance to
|
exceptions happen so that interactive debuggers have a chance to
|
||||||
introspect the data. With 0.4 this can also be forced for requests
|
introspect the data. With 0.4 this can also be forced for requests
|
||||||
that did not fail and outside of `DEBUG` mode. By setting
|
that did not fail and outside of ``DEBUG`` mode. By setting
|
||||||
``'flask._preserve_context'`` to ``True`` on the WSGI environment the
|
``'flask._preserve_context'`` to ``True`` on the WSGI environment the
|
||||||
context will not pop itself at the end of the request. This is used by
|
context will not pop itself at the end of the request. This is used by
|
||||||
the :meth:`~flask.Flask.test_client` for example to implement the
|
the :meth:`~flask.Flask.test_client` for example to implement the
|
||||||
|
|
|
@ -245,7 +245,7 @@ def url_for(endpoint, **values):
|
||||||
:param endpoint: the endpoint of the URL (name of the function)
|
:param endpoint: the endpoint of the URL (name of the function)
|
||||||
:param values: the variable arguments of the URL rule
|
:param values: the variable arguments of the URL rule
|
||||||
:param _external: if set to ``True``, an absolute URL is generated. Server
|
:param _external: if set to ``True``, an absolute URL is generated. Server
|
||||||
address can be changed via `SERVER_NAME` configuration variable which
|
address can be changed via ``SERVER_NAME`` configuration variable which
|
||||||
defaults to `localhost`.
|
defaults to `localhost`.
|
||||||
:param _scheme: a string specifying the desired URL scheme. The `_external`
|
:param _scheme: a string specifying the desired URL scheme. The `_external`
|
||||||
parameter must be set to ``True`` or a `ValueError` is raised. The default
|
parameter must be set to ``True`` or a `ValueError` is raised. The default
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Request(RequestBase):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_content_length(self):
|
def max_content_length(self):
|
||||||
"""Read-only view of the `MAX_CONTENT_LENGTH` config key."""
|
"""Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""
|
||||||
ctx = _request_ctx_stack.top
|
ctx = _request_ctx_stack.top
|
||||||
if ctx is not None:
|
if ctx is not None:
|
||||||
return ctx.app.config['MAX_CONTENT_LENGTH']
|
return ctx.app.config['MAX_CONTENT_LENGTH']
|
||||||
|
|
Loading…
Reference in New Issue