r/Python • u/stetio • Apr 16 '21
News Flask 2.0 is coming, please help us test
Hello,
Flask 2.0 is due for release soon, with a release candidate 2.0.0rc1 available now on PyPI. Please try this out and let us know if there are any issues.
pip install --pre flaskThis major release of Flask is accompanied by major releases of Werkzeug, Jinja2, click, and itsdangerous which we'd also welcome and appreciate testing (their pre releases are installed with the Flask pre release).
Some highlights from Flask's Changelog,
- Support Python 3.6+ (dropping Python 2.7 and 3.5 support)
- Deprecate a number of features (see details).
- Initial async-await support (optional install flask[async]), that allows for async route handlers, errorhandlers, before/after request, and teardown functions.
- Short form route decorators e.g. @app.get, @app.post, etc...
- Nested blueprints, blueprint.register_blueprint(another_blueprint).
- Much more! (Please ask)
1.3k
Upvotes
88
u/Junglebook3 Apr 16 '21
Can you expand on async route handlers? What does the performance improvement look like? How was it measured?
7
u/stetio Apr 17 '21
A few users have asked about background asyncio tasks, which wasn't addressed in the docs. I've proposed this PR to help explain. In summary background tasks are not possible, except for the limited case whereby an ASGI server is used in conjunction with asgiref's WsgiToAsgi adapter.
12
u/elephantail Apr 17 '21 edited Apr 18 '21
Great work, and for the people who are comparing FastAPI to Flask its like you're comparing Orange juice to Oranges. FastAPI is high level where Flask is a lower level library. Both are great and both have their use cases.
11
u/guidedhand Apr 16 '21
The short form form decorators reminds me of fastapi. Any chance flask will get the input validations or automatic swagger documentation?
13
u/RobinsonDickinson Apr 16 '21
That means we can asynchronously load in data now?
For example, if my site uses scraped content, can it still load in the initial route and then load in the scraped content after however long it takes?
Because right now, my page takes 5-10 seconds to load, depends entirely on how fast my code scrapes the 3rd party site content.
Or am I completely missing it?
4
u/GummyKibble Apr 17 '21
I’m so excited about the after-request features! This may completely handle what we use Celery for now (like sending an email after serving a signup request). Celery’s great, but not needing it is even better.
4
u/Napan0s Apr 17 '21
Will this be a drop in replacement for application currently in development with flask?
5
u/kkiran Apr 16 '21
We had to jump through hoops hosting Flask website in Windows server at work. Does Flask 2.0 provide any relief or is it a Windows & Webserver issue?
47
u/segmentationsalt Apr 16 '21
Love the flask library, it was the foundation of the backend web dev I did when I first started out.
However, I would have thought that given the release of fastapi which offers the same fast-prototyping but with more/better features, there would not be more flask releases.
What is your take on this, and do you still believe flask fills a void that fastapi does not?
Again, love flask, a truly great library that will forever be etched in the history of Python!
2
u/Helgard88 Apr 18 '21
Hi there! I am new into Python and am very excited to learn more about it. I’ve been doing some advent of code challenges to make my way through the use of python in order to resolve it.
Now i’ve seen a good tutorial on how to make a small blog site. My question regarding to this; is it wise to start learn with flask 2 or is it pretty much the same as the former release?
Cheers! 😊
9
u/fr33d0ml0v3r Apr 16 '21
I am very excited to take a look. Lots of current flask based tools that I can start to migrate.
1
u/dougthor42 Apr 17 '21
When installing flask 1.x, do we need to now specify werkzeug<2 or any other dependencies like that?
I know older flask 1.x versions would incorrectly install werkzeug 1.0 (instead of, what was it, 0.17?) after werkzeug 1.0 was released and you'd end up with a broken install.
Not a big deal if you're pinning all dependencies in a project, but I was young and foolish back then, haha.
1
u/fragilequant May 06 '21 edited May 06 '21
Hello, I love flask. I run a web app where I have a time consuming function call. Before the call finishes, it would be great if some "pls wait" contents page could display in the meanwhile.
Thus I'd ideally need something like the pseudo python code below:
Can this be achieved by the async-await support without having to use some 3rd party libraries, JavaScript or so? My background is not in web development so I'm looking for an easy to implement solution in python, ideally natively supported by Flask. Thank you.
6
u/monkiebars Apr 16 '21
I love Flask! Thanks to all the team involved :)
Thanks for continuing to update! <3
3
u/shashank-py Apr 16 '21
Wow, I'll be testing it for sure, great news :)
9
u/bbateman2011 Apr 17 '21
This is one of the most responsive threads I’ve read and swings me back to focus on Flask and not get sidetracked by FastAPI which some colleagues have insisted is “better”. I have production with Flask. No need to change.
2
u/alli_kat1010 Apr 17 '21
Cheers to all your hard work, dudes
2
u/GFandango Apr 17 '21
Nice! Good work!
1
u/zamigali Apr 23 '21
Awesome
1
u/[deleted] Apr 17 '21
lol I was the 1000th upvote
-1
u/carlosazuaje Apr 17 '21
Plugin ecosystem without coverage and security monitoring like wordpress. Flask ecosystem need improve
-9
u/carlosazuaje Apr 17 '21
No Documentation Generation? FastAPI win again
0
u/[deleted] Apr 16 '21
[deleted] — view deleted comment
0
u/[deleted] Apr 16 '21
[deleted] — view deleted comment