◆ __init__()
def __init__ |
( |
|
self, |
|
|
|
import_name, |
|
|
|
template_folder = None , |
|
|
|
root_path = None |
|
) |
| |
◆ get_send_file_max_age()
def get_send_file_max_age |
( |
|
self, |
|
|
|
filename |
|
) |
| |
Provides default cache_timeout for the :func:`send_file` functions.
By default, this function returns ``SEND_FILE_MAX_AGE_DEFAULT`` from
the configuration of :data:`~flask.current_app`.
Static file functions such as :func:`send_from_directory` use this
function, and :func:`send_file` calls this function on
:data:`~flask.current_app` when the given cache_timeout is ``None``. If a
cache_timeout is given in :func:`send_file`, that timeout is used;
otherwise, this method is called.
This allows subclasses to change the behavior when sending files based
on the filename. For example, to set the cache timeout for .js files
to 60 seconds::
class MyFlask(flask.Flask):
def get_send_file_max_age(self, name):
if name.lower().endswith('.js'):
return 60
return flask.Flask.get_send_file_max_age(self, name)
.. versionadded:: 0.9
◆ has_static_folder()
def has_static_folder |
( |
|
self | ) |
|
This is ``True`` if the package bound object's container has a
folder for static files.
.. versionadded:: 0.5
◆ jinja_loader()
The Jinja loader for this package bound object.
.. versionadded:: 0.5
◆ open_resource()
def open_resource |
( |
|
self, |
|
|
|
resource, |
|
|
|
mode = "rb" |
|
) |
| |
Opens a resource from the application's resource folder. To see
how this works, consider the following folder structure::
/myapplication.py
/schema.sql
/static
/style.css
/templates
/layout.html
/index.html
If you want to open the :file:`schema.sql` file you would do the
following::
with app.open_resource('schema.sql') as f:
contents = f.read()
do_something_with(contents)
:param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator.
:param mode: Open file in this mode. Only reading is supported,
valid values are "r" (or "rt") and "rb".
◆ send_static_file()
def send_static_file |
( |
|
self, |
|
|
|
filename |
|
) |
| |
Function used internally to send static files from the static
folder to the browser.
.. versionadded:: 0.5
◆ static_folder() [1/2]
def static_folder |
( |
|
self | ) |
|
The absolute path to the configured static folder.
◆ static_folder() [2/2]
def static_folder |
( |
|
self, |
|
|
|
value |
|
) |
| |
◆ static_url_path() [1/2]
def static_url_path |
( |
|
self | ) |
|
The URL prefix that the static route will be accessible from.
If it was not configured during init, it is derived from
:attr:`static_folder`.
◆ static_url_path() [2/2]
def static_url_path |
( |
|
self, |
|
|
|
value |
|
) |
| |
◆ cli
◆ import_name
◆ root_path
◆ template_folder
The documentation for this class was generated from the following file:
- /home/passerat/Stage/flaskProject/venv/lib/python3.8/site-packages/flask/helpers.py