Commit graph

145 commits

Author SHA1 Message Date
David Lord
7c5261407d
blueprint name may not contain a dot 2021-05-13 14:31:50 -07:00
Grey Li
d5aadba4d3
improve type hints for send_file and send_from_directory 2021-05-13 13:33:07 -07:00
David Lord
25884c433f
fix typing that wasn't available in Python 3.6.0 2021-05-13 13:06:32 -07:00
David Lord
6fe7f45725
inform mypy that g has arbitrary attributes 2021-05-13 13:06:32 -07:00
David Lord
89475e5d1e
mark top-level names as exported 2021-05-13 11:36:05 -07:00
Grey Li
fc82dd50e3
Re-add filename param for send_from_directory
Add a deprecation warning for the old name
2021-05-12 10:15:55 -07:00
David Lord
6fb1101f70
start version 2.0.1.dev0 2021-05-11 14:48:08 -07:00
David Lord
f8e63d3991
release version 2.0.0 2021-05-11 14:41:52 -07:00
Grey Li
9be01564f2 Update changelog for #3932 2021-04-28 14:20:44 +08:00
Adrian Moennich
26a6cc0f94 Allow using Click 7 with a DeprecationWarning
As long as popular libraries (e.g. Celery) require click 7, depending
on Click 8 in Flask makes it hard to test the latest version (and its
other dependencies) in existing applications.
2021-04-27 16:45:06 +02:00
David Lord
1a8549debb
Merge pull request #3973 from pgjones/typing 2021-04-27 07:32:10 -07:00
pgjones
77237093da Add initial type hints
This should make it easier for users to correctly use Flask. The hints
are from Quart.
2021-04-26 17:29:53 +01:00
David Lord
e6e75e5547
changelog for bumped pallets versions 2021-04-24 07:31:16 -07:00
David Lord
85b430a366
deprecate total_seconds 2021-04-15 23:14:53 -07:00
David Lord
32272da9ac
shell calls sys.__interativehook__
This will set up readline tab and history completion by default.
2021-04-14 10:01:32 -07:00
pgjones
f92e820b4b
Nested blueprints
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
2021-04-14 09:25:42 -07:00
pgjones
6979265fa6
Add async support
This allows for async functions to be passed to the Flask class
instance, for example as a view function,

    @app.route("/")
    async def index():
        return "Async hello"

this comes with a cost though of poorer performance than using the
sync equivalent.

asgiref is the standard way to run async code within a sync context,
and is used in Django making it a safe and sane choice for this.
2021-04-06 09:35:10 -07:00
pgjones
705e52684a
Add syntatic sugar for route registration
This takes a popular API whereby instead of passing the HTTP method as
an argument to route it is instead used as the method name i.e.

    @app.route("/", methods=["POST"])

is now writeable as,

    @app.post("/")

This is simply syntatic sugar, it doesn't do anything else, but makes
it slightly easier for users.

I've included all the methods that are relevant and aren't auto
generated i.e. not connect, head, options, and trace.
2021-03-08 08:55:14 -08:00
David Lord
b473e7c97c
use Jinja's tojson filter 2021-02-01 22:48:09 -08:00
Matthew Preble
01621485fd
Ensure session_interface.open_session is called after URL matching (#3776) 2021-02-01 20:41:17 -08:00
David Lord
14f56363a4
rename send_file add_etags to etag 2021-01-29 10:52:48 -08:00
David Lord
dc11cdb4a4
move send_file and send_from_directory to Werkzeug
The implementations were moved to Werkzeug, Flask's functions become
wrappers around Werkzeug to pass some Flask-specific values.

cache_timeout is renamed to max_age. SEND_FILE_MAX_AGE_DEFAULT,
app.send_file_max_age_default, and app.get_send_file_max_age defaults
to None. This tells the browser to use conditional requests rather than
a 12 hour cache.

attachment_filename is renamed to download_name, and is always sent if
a name is known.

Deprecate helpers.safe_join in favor of werkzeug.utils.safe_join.

Removed most of the send_file tests, they're tested in Werkzeug.

In the file upload example, renamed the uploaded_file view to
download_file to avoid a common source of confusion.
2020-11-05 09:27:52 -08:00
David Lord
15a49e7297
Merge branch '1.1.x' 2020-11-04 18:25:37 -08:00
Mathurshan Vimalesvaran
22987b6817
include samesite and secure when removing session cookie (#3726) 2020-11-04 18:16:05 -08:00
yk396
b146a13f63
extract common Flask/Blueprint API to Scaffold base class
Co-authored-by: Chris Nguyen <chrisngyn99@gmail.com>
2020-08-01 07:45:58 -07:00
David Lord
253570784c
cleaner message when CLI can't load app
When loading the app fails for the --help command, only the error
message is shown, then the help text. The full traceback is shown for
other exceptions. Also show the message when loading fails while
getting a command, instead of only "command not found". The error
message goes to stderr to match other error behavior, and is in red
with an extra newline to make it more obvious next to the help text.

Also fixes an issue with the test_apps fixture that caused an imported
app to still be importable after the test was over and the path was
reset. Now the module cache is reset as well.
2020-07-30 18:36:55 -07:00
Christopher Nguyen
7b09a0904c
change make_response to use headers.update 2020-07-23 16:53:39 -07:00
Joshua Bronson
a40c381ffd
Merge pull request #3560 from greyli/fix-env-chdir
Stop change CWD to .env/.flaskenv location
2020-07-18 13:14:09 -04:00
Joshua Bronson
b724832872 Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder) 2020-07-06 13:47:57 -04:00
Joshua Bronson
7ba35c4d4f Restore support for using pathlib.Path for static_folder.
* No longer causes AttributeError: 'PosixPath' object has no
  attribute 'rstrip'.

* This was broken by e6178fe489
  which was released in 1.1.2.

* Add a regression test that now passes.

See #3557.
2020-07-06 08:55:19 -04:00
Grey Li
e403e9ea97 Update changelog for load dotenv behaivour change 2020-07-05 09:38:48 +08:00
David Lord
ff2f71379b
use ast to parse FLASK_APP
enables keyword arguments to factory functions
2020-04-07 17:54:51 -07:00
David Lord
fcac7f11cf
deprecate passing script_info to factory 2020-04-07 15:54:36 -07:00
David Lord
756902cca1
update json docs 2020-04-07 13:37:14 -07:00
David Lord
c43edfc7c0
remove simplejson
- remove encoding detection backport, json.loads supports it directly
- use str.translate instead of multiple str.replace
2020-04-07 09:55:39 -07:00
David Lord
a0a61acdec
drop support for Python 2.7 and 3.5 2020-04-04 12:09:55 -07:00
David Lord
7673835b3d
remove Python 2 from docs 2020-04-04 12:05:44 -07:00
David Lord
96b4dcafc3
Merge branch '1.1.x' 2020-04-03 10:25:51 -07:00
David Lord
93dd1709d0
release version 1.1.2 2020-04-03 10:10:38 -07:00
David Lord
64ba43411f
Merge remote-tracking branch 'origin/1.1.x' 2020-02-15 10:40:32 -08:00
frostming
d4076cf07c
strip the ending slash for static_url_path 2020-02-10 18:19:25 -08:00
David Lord
bcde664f9a
cli checks for cryptography library 2020-02-10 17:34:19 -08:00
David Lord
ab6e630194
Merge branch '1.1.x' 2020-02-10 16:44:33 -08:00
David Lord
ef27c1b749
Merge branch '1.0.x' into 1.1.x 2020-02-10 16:43:49 -08:00
David Lord
d92b64aa27
clean up merge 2020-02-10 16:36:40 -08:00
Armin Ronacher
5ceb0a59dd Merge branch '1.1.x' 2020-02-10 20:37:28 +01:00
Armin Ronacher
9b424e9da9 Merge branch '1.0.x' into 1.1.x 2020-02-10 20:37:21 +01:00
Armin Ronacher
2f8086e8c8 Merge remote-tracking branch 'origin/0.12.x' into 1.0.x 2020-02-10 20:36:55 +01:00
David Lord
8d5234e4c7
next version 1.2.0 2020-02-09 15:20:23 -08:00
David Lord
980168d084
send_file doesn't allow StringIO 2019-11-19 08:52:12 -08:00