Commit graph

129 commits

Author SHA1 Message Date
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
David Lord
240a11052b
lazy load app on reload only 2019-11-18 17:54:46 -08:00
David Lord
aac0f585b9
clean up config.from_file docs 2019-10-18 09:24:58 -07:00
Doron Horwitz
0c0b31a789
get_cookie_name in SessionInterface for easier overriding in SecureCookieSessionInterface 2019-10-12 19:12:27 -07:00
David Lord
ded3d642a7
pass sys.argv to flask cli 2019-07-10 12:44:04 -07:00
David Lord
c478e5d52f
pass sys.argv to flask cli 2019-07-10 11:45:20 -07:00
David Lord
ffc68840f8
release version 1.1.1 2019-07-08 10:58:12 -07:00
David Lord
1617202d91
restore and deprecate json_available 2019-07-08 10:26:12 -07:00
David Lord
1b4ace9ba5
release version 1.1.0 2019-07-04 16:04:42 -07:00
David Lord
8a78fdb09c
Merge branch '1.0.x' 2019-07-04 16:01:14 -07:00
David Lord
626b5cc166
release version 1.0.4 2019-07-04 15:33:46 -07:00
David Lord
2844fdb82e
Merge branch '1.0.x' 2019-07-03 12:23:16 -07:00
ThiefMaster
975f979269 Move dotenv warning to stderr 2019-07-03 15:08:10 +02:00
David Lord
b08e35e4ab
show warning for old logger config 2019-07-02 11:39:00 -07:00
David Lord
df470aecb9
use app.name as app.logger name 2019-07-01 14:56:18 -07:00
David Lord
b05a685a03
Merge branch '1.0.x' 2019-07-01 10:54:31 -07:00
Anthony Sottile
a5ecdfa7a5
Fixes for PEP451 import loaders and pytest 5.x
- pytest 5.x drops python2 compatibility and therefore only implements PEP 451
- pytest 5.x made the repr of `ExcInfo` less confusing (fixed tests depending
  on the old format)
2019-07-01 10:43:06 -07:00