Skip to content

Commit 4c2da72

Browse files
committed
adding additional flask example descriptions
1 parent 1d17eee commit 4c2da72

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

content/pages/examples/flask/flask-globals-current-app.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ from the Werkzeug framework. `current_app` can be used to access data about the
1515
running application, including the configuration. This is useful for both
1616
developers using the framework and ones building extensions for Flask.
1717

18+
You will often see `current_app` imported directly from `flask` instead
19+
of `flask.globals`. These imports are equivalent because `flask` is simply
20+
importing `current_app` from `flask.globals`.
21+
1822

1923
## Example 1 from Flask AppBuilder
2024
[Flask-AppBuilder](https://github.com/dpgaspar/Flask-AppBuilder)

content/pages/examples/flask/flask-globals-g.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ an object for storing data during the
1212
[application context](https://flask.palletsprojects.com/en/1.1.x/appcontext/)
1313
of a running [Flask](/flask.html) web app.
1414

15+
`g` can also be imported directly from the `flask` module instead
16+
of `flask.globals`, so you will often see that shortcut in example code.
17+
1518

1619
## Example 1 from Flask AppBuilder
1720
[Flask-AppBuilder](https://github.com/dpgaspar/Flask-AppBuilder)

content/pages/examples/flask/flask-helpers-get-root-path.markdown

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ sidebartitle: flask.helpers get_root_path
77
meta: Python example code that shows how to use the get_root_path callable from the flask.helpers module of the Flask project.
88

99

10-
get_root_path is a callable within the flask.helpers module of the Flask project.
10+
[get_root_path](https://github.com/pallets/flask/blob/master/src/flask/helpers.py)
11+
is a function within the `flask.helpers` module of the [Flask](/flask.html)
12+
framework. `get_root_path` returns the filesystem path to a package
13+
or the current working directly if the path cannot be found.
1114

1215

1316
## Example 1 from indico

content/pages/examples/flask/flask-helpers-make-response.markdown

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ sidebartitle: flask.helpers make_response
77
meta: Python example code that shows how to use the make_response callable from the flask.helpers module of the Flask project.
88

99

10-
make_response is a callable within the flask.helpers module of the Flask project.
10+
[make_response](https://github.com/pallets/flask/blob/master/src/flask/helpers.py)
11+
is a function in the `flask.helpers` module of the [Flask](/flask.html)
12+
[web framework](/web-framework.html). `make_response` is for adding additional
13+
HTTP headers to a response within a view's code. Sometimes views do not return
14+
a response object so it's unclear how to add headers to the response, which
15+
is where `make_response` is particularly useful in solving that specific
16+
problem.
17+
18+
`make_response` can also be imported directly from the `flask` module
19+
instead of `flask.helpers` so you will typically see that shortcut
20+
in example code.
1121

1222

1323
## Example 1 from Flask AppBuilder

content/pages/examples/flask/flask-helpers-send-file.markdown

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ sidebartitle: flask.helpers send_file
77
meta: Python example code that shows how to use the send_file callable from the flask.helpers module of the Flask project.
88

99

10-
send_file is a callable within the flask.helpers module of the Flask project.
10+
[send_file](https://github.com/pallets/flask/blob/master/src/flask/helpers.py)
11+
is function in the [Flask](/flask.html) `flask.helpers` module.
12+
`send_file` transfers the contents of a file to the client using the most
13+
efficient method available and configured in the Flask settings. It
14+
attempts to guess the correct mimetype to use but it can also be
15+
explicitly configured.
16+
17+
Note that `send_file` is usually imported directly from `flask` instead of
18+
from `flask.helpers`, even though it is defined within the `helpers` module.
19+
It's the same function that is imported, but it's less characters to type
20+
when you leave off the `.helpers` part.
1121

1222

1323
## Example 1 from Flask-VueJs-Template

content/pages/examples/flask/flask-helpers-url-for.markdown

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ sidebartitle: flask.helpers url_for
77
meta: Python example code that shows how to use the url_for callable from the flask.helpers module of the Flask project.
88

99

10-
url_for is a callable within the flask.helpers module of the Flask project.
10+
[url_for](https://github.com/pallets/flask/blob/master/src/flask/helpers.py)
11+
is function in the [Flask](/flask.html) `flask.helpers` module.
12+
`url_for` generates a URL to an endpoint using the method passed in
13+
as an argument.
14+
15+
Note that `url_for` is typically imported directly from `flask` instead of
16+
from `flask.helpers`, even though it is defined within the `helpers` module.
17+
It is the same function that is imported, but it's less characters to type
18+
when you leave off the `.helpers` part.
1119

1220

1321
## Example 1 from Flask AppBuilder

0 commit comments

Comments
 (0)