Commit graph

163 commits

Author SHA1 Message Date
default-303
6ca89fdfe7 Fix typing of jinja decorators (#4109) 2021-05-29 20:54:35 +02:00
Marat Sharafutdinov
28f4e7464a Fix type annotation for before_request and before_app_request decorators 2021-05-25 18:29:52 +00:00
Pascal Corpet
81c637ff1d improve typing for teardown_request 2021-05-24 19:28:57 +00:00
David Lord
af4a5b841e start version 2.0.2.dev0 2021-05-21 08:55:31 -07:00
David Lord
e681adb826 release version 2.0.1 2021-05-21 08:50:31 -07:00
David Lord
d883eb2ab5 improve typing for stream_with_context 2021-05-21 08:42:44 -07:00
David Lord
020ac5f2d9 warn when registering same blueprint with same name 2021-05-21 15:04:30 +01:00
David Lord
4907999188 changelog for blueprint registered name 2021-05-21 15:04:30 +01:00
Alex Hedges
7fb6d79770 Update CHANGES.rst 2021-05-21 08:09:05 +00:00
David Lord
58e5ba2980 re-add deprecated Config.from_json method 2021-05-20 13:50:13 -07:00
David Lord
bd3a8b71f8 converters have access to session 2021-05-14 08:11:09 -07:00
David Lord
919966dd0e Merge branch '1.1.x' into 2.0.x 2021-05-13 18:47:06 -07:00
David Lord
582339292a release version 1.1.4 2021-05-13 18:22:56 -07:00
brettlangdon
289dad68e8 Use compat fspath instead of os.fspath
When 7ba35c4 was cherry-picked it introduced the
usage of os.fspath which is not supported on
Python <3.6
2021-05-13 18:17:00 -07:00
David Lord
5ae521f365 Merge branch '1.1.x' into 2.0.x 2021-05-13 16:34:58 -07:00
David Lord
5d18fbb512 release version 1.1.3 2021-05-13 16:22:57 -07:00
David Lord
7df523231c set maximum versions of pallets dependencies 2021-05-13 16:16:45 -07:00
Grey Li
ad15cd639e fix url_prefix argument when nesting blueprints 2021-05-13 15:02:13 -07:00
David Lord
2e3276e3dd blueprint name may not contain a dot 2021-05-13 14:31:50 -07:00
Grey Li
702529eb9c improve type hints for send_file and send_from_directory 2021-05-13 13:33:07 -07:00
David Lord
78519d52e4 fix typing that wasn't available in Python 3.6.0 2021-05-13 13:06:32 -07:00
David Lord
7c738c6fcb inform mypy that g has arbitrary attributes 2021-05-13 13:06:32 -07:00
David Lord
4edf300c40 mark top-level names as exported 2021-05-13 11:36:05 -07:00
Grey Li
811bc1b01c 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
269e8782ac start version 2.0.1.dev0 2021-05-11 14:48:08 -07:00
David Lord
a55e2500ab release version 2.0.0 2021-05-11 14:41:52 -07:00
Grey Li
de8fa20fac Update changelog for #3932 2021-04-28 14:20:44 +08:00
Adrian Moennich
d235ab0faa 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
2394ce4208 Merge pull request #3973 from pgjones/typing 2021-04-27 07:32:10 -07:00
pgjones
fa5c99ef4f 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
cba97ff101 changelog for bumped pallets versions 2021-04-24 07:31:16 -07:00
David Lord
96ea4be346 deprecate total_seconds 2021-04-15 23:14:53 -07:00
David Lord
962b55b9b6 shell calls sys.__interativehook__
This will set up readline tab and history completion by default.
2021-04-14 10:01:32 -07:00
pgjones
257c7c5c2a 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
c9f774d650 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
26932dad46 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
39d978f42b use Jinja's tojson filter 2021-02-01 22:48:09 -08:00
Matthew Preble
5aa2518a34 Ensure session_interface.open_session is called after URL matching (#3776) 2021-02-01 20:41:17 -08:00
David Lord
378d13aa1b rename send_file add_etags to etag 2021-01-29 10:52:48 -08:00
David Lord
26bb6b1c56 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
d81e5f8b6c Merge branch '1.1.x' 2020-11-04 18:25:37 -08:00
Mathurshan Vimalesvaran
8819687447 include samesite and secure when removing session cookie (#3726) 2020-11-04 18:16:05 -08:00
yk396
a37cbe4fbb 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
8b9128ee06 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
95653896a4 change make_response to use headers.update 2020-07-23 16:53:39 -07:00
Joshua Bronson
06f7f34d76 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
35b8f096a7 Cherry-pick 7ba35c4 from master (support pathlib.Path for static_folder) 2020-07-06 13:47:57 -04:00
Joshua Bronson
f81846c68b 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
8fb45cc419 Update changelog for load dotenv behaivour change 2020-07-05 09:38:48 +08:00
David Lord
042754ba4a use ast to parse FLASK_APP
enables keyword arguments to factory functions
2020-04-07 17:54:51 -07:00