News for hackers. Stuff that matters.
Re:Flask Mega-Tutorial (2017) by miguelgrinberg on Monday May 30, 2022 @05:37AM (#31557147)
Flask Mega-Tutorial author here. This was a surprise. :)

Happy to see people continue to find my tutorial useful and relevant. If you have any questions, I'll be happy to answer.

Re:Flask Mega-Tutorial (2017) by kyle_morris_ on Monday May 30, 2022 @08:54AM (#31558477)
Your tutorials were a huge influence on me as I began learning to code in my late 20’s and had a profound impact allowing me to start two companies and helped give me a toolset I didn’t have before. Thanks for all you do!
Re:Flask Mega-Tutorial (2017) by iknownothow on Monday May 30, 2022 @06:20AM (#31557391)
What do you think about the current state of Flask and Flask extensions? Are they being maintained and up to date? Or would it better to go with FastAPI and use its non-async features to have the same Flask like experience?
Re:Flask Mega-Tutorial (2017) by miguelgrinberg on Monday May 30, 2022 @06:31AM (#31557484)
Something that I think not everybody realizes is that Flask does not require extensions for most things. The extensions are nice because they integrate with the Flask configuration object, and with before/after request handlers when it makes sense, but none of that is required. If an extension stops being maintained, you can always find a newer general purpose Python package that does what you need and just use it in your Flask app.

Now this is my personal opinion, but you cannot say the same about FastAPI. Even though the ecosystem of asyncio compatible libraries has grown, it is still several orders of magnitude smaller than what is available for standard non-async Python. So in my view, in terms of access to 3rd party libraries Flask is a better choice.

Re:Flask Mega-Tutorial (2017) by CharlieDavies on Monday May 30, 2022 @06:36AM (#31557528)
But if you use FastAPI and completely ignore the async aspects, you get some handy tools out of the box, Swagger/Pydantic integration being the big one. Then you're in roughly the same place as Flask where you're just using general python packages. I struggle to see any advantages to Flask vs one of Django or FastAPI at this point.
Re:Flask Mega-Tutorial (2017) by joaodlf on Monday May 30, 2022 @06:49AM (#31557619)
This is probably quite unpopular, seeing as the FastAPI docs have been so praised in the past... but I really dislike how FastAPI is documented, which has really put me off of the project.

The FastAPI docs read like a full project, a very dense project. Sometimes you just want to learn about a specific feature, but you walk into a page that assumes you have the context of the previous chapters, that puts me off a lot.

I also dislike how some of the documentation is absolutely enormous (the SQL chapters is one example), but I suspect this might have to do with the not-so-simple approach FastAPI takes, as opposed to Flask, which is indeed very simple.

I really can't join the crowd here. I don't think FastAPI is a replacement for Flask, even when async is taken out of the equation. Flask has some weird quirks to it (like "g"), but it really is a beautiful and simple API for the web.

Re:Flask Mega-Tutorial (2017) by misnome on Monday May 30, 2022 @06:54AM (#31557648)
I like FastAPI and using it feels nice.

But it could _really_ do with some "Reference" documentation. Sometimes I just want to know exactly what a call does or what the various parameters mean.

Re:Flask Mega-Tutorial (2017) by a1445c8b on Monday May 30, 2022 @07:31AM (#31557891)
I agree. There are generally 4 types of documentation as per the diagram in this page[0] and FastAPI’s solely focuses on the top left quadrant and falls flat on the lower right.

[0] https://documentation.divio.com/

Re:Flask Mega-Tutorial (2017) by CharlieDavies on Monday May 30, 2022 @07:56AM (#31558064)
I agree with you entirely about the issues with the docs, there is no API reference, and Tiangolo has rejected PRs with automated documentation before. I by no means think the project is perfect, but I think it is a better starting point for most small projects. I just don't see any advantage to Flask at this point unless you specifically want to use one of tiny handful of Flask-X packages that are actually worthwhile.
Re:Flask Mega-Tutorial (2017) by timojeajea on Monday May 30, 2022 @09:03AM (#31558540)
One major advantage Flask has over FastAPI is maturity. FastAPI has 1000+ open issues on Github vs 14 for Flask. That is quite scary.
Re:Flask Mega-Tutorial (2017) by wdroz on Monday May 30, 2022 @02:13PM (#31561862)
It's interesting the see the number of open issues of popular python projects:

Pytorch, 8400

Pandas, 3400

Tensorflow, 2100

jupyter notebook, 2000

scikit-learn, 1500

pytest, 720

requests, 170

The outlier seem to be Flask.

Re:Flask Mega-Tutorial (2017) by timojeajea on Thursday June 02, 2022 @04:39AM (#31592722)
You picked mainly data science python projects. It would make more sense to compare with other python web frameworks.

django, 1101 open, 32662 closed

cherrypy, 218 open, 1505 closed

starlette, 31 open, 570 closed

pyramid, 70 open, 966 closed

falcon, 168 open, 789 closed

flask, 14 open, 2318 closed

fastapi, 1044 open, 1855 closed

Fast api has one of the worst ratio regarding open/closed issues.

Re:Flask Mega-Tutorial (2017) by wdroz on Thursday June 02, 2022 @08:47AM (#31594123)
I wanted to add django but their issues aren't on github as they are using their own system. IMO an external issue tracker lead to a higher barrier to create new issues, so this isn't not necessary fair.

Also fastapi allows people to ask questions with the issues. On the 1000+ open issues, 826 are tagged as question.

It's hard to find a fair metric. Open/close ratio rewards older project with fluctuating/stable popularity. Fastapi popularity is still growing[0], so having some difficulties to work on issues is expected.

[0] -- https://trends.google.com/trends/explore?date=today%205-y&q=...

Re:Flask Mega-Tutorial (2017) by miguelgrinberg on Monday May 30, 2022 @07:01AM (#31557699)
Not sure what you mean by "ignoring async". If you write your handlers as regular functions, I would imagine FastAPI is going to send them to run in an executor. So all the concurrency benefits of FastAPI go down the drain, and now your concurrency is based on threads.

As far as Swagger integration, you can use APIFairy with Flask and get similar type of auto-generated docs. Disclaimer, APIFairy is an extension that I created: https://github.com/miguelgrinberg/APIFairy

Re:Flask Mega-Tutorial (2017) by DandyDev on Monday May 30, 2022 @07:30AM (#31557880)
But then it would be on par with Flask, both performance wise and with regards to integration with third party libraries. That is how I'm currently using FastAPI, with regular sync SQLAlchemy for example.

The difference is that even without the benefits of async, FastAPI offers a vastly better developer experience IMHO, with its integration with Pydantic, Python type hints and the lack of reliance on global objects

Re:Flask Mega-Tutorial (2017) by miguelgrinberg on Monday May 30, 2022 @09:59AM (#31559031)
I think you are oversimplifying this. If you don't know how FastAPI handles sync code, then you can't claim it is on par with Flask. I suggested it might use an executor, after looking in their code, they use a thread pool support in Starlette, which in turns imports this thread pool logic from AnyIO. I see no easy way to determine what is the size of the pool. Clearly this isn't designed as a main way to run code, it is just a quick way to run sync code w/o blocking the loop. I would not consider this up to par with the concurrency you get from Gunicorn or uWSGI using a configurable thread or process pool.
Re:Flask Mega-Tutorial (2017) by alejoar on Monday May 30, 2022 @08:40AM (#31558343)
Hey Miguel, I got my first web developer job right after reading you Flask Web Development book in the summer of 2015. Thanks!
Re:Flask Mega-Tutorial (2017) by cushychicken on Monday May 30, 2022 @11:16AM (#31559925)
One more thank you note can't hurt.

Your Flask tutorials are my webapp I Ching. Thanks a bunch. Just about to launch another Flask webapp in the next few weeks, and your tutorials are invaluable.

Oh! Before I forget - flask-migrate! Lifesaver! Thanks Miguel!

Re:Flask Mega-Tutorial (2017) by john-radio on Monday May 30, 2022 @07:47AM (#31558006)
Your work really got me off the ground with web dev, man. Thank you.
Re:Flask Mega-Tutorial (2017) by hkt on Monday May 30, 2022 @06:35AM (#31557521)
No questions, just praise: I loved this tutorial, it was hugely helpful to me when I was just getting into python and I regularly recommend it. Thanks for writing it and sharing it!
Re:Flask Mega-Tutorial (2017) by manugarri on Monday May 30, 2022 @09:04AM (#31558552)
Your mega post made me learn web development almost a decade ago!, thanks a lot!
Re:Flask Mega-Tutorial (2017) by tsumnia on Monday May 30, 2022 @12:00PM (#31560363)
Same as most of the replies, just wanted to send my thanks for the tutorial. I used your original tutorial (before the function name change) for my dissertation platform and its been running for 6 years now.
Re:Flask Mega-Tutorial (2017) by agumonkey on Monday May 30, 2022 @02:47PM (#31562246)
Hi, I never finished your tut but it was a impressive to see the surface covered. I'm curious, are you still using flask ? have you tried FastAPI or Django or something else ?

Thanks again

Re:Flask Mega-Tutorial (2017) by teruakohatu on Monday May 30, 2022 @05:50AM (#31557219)
Is flask-admin worth using? Or any other auto-admin type libraries?
Re:Flask Mega-Tutorial (2017) by miguelgrinberg on Monday May 30, 2022 @05:57AM (#31557253)
This is really a matter of preference. I do not use Flask-Admin on my projects, I have always preferred to design my own admin pages than being forced to accept the choices that are imposed by these big extensions. This allows me to have a consistent UI across admin and non-admin pages.

One thing that people often complain is that it is hard and/or tedious to build tables with data, which is one of the building blocks most admin pages need. Last year I wrote a blog article where I show how I build tables in my Flask apps: https://blog.miguelgrinberg.com/post/beautiful-interactive-t....

Re:Flask Mega-Tutorial (2017) by zach_garwood on Monday May 30, 2022 @10:34AM (#31559406)
I think that Flask has many great extensions, but in my opinion, installing flask-admin is just a tacit admission that you really wanted to use Django instead.
Re:Flask Mega-Tutorial (2017) by mgraupner on Monday May 30, 2022 @07:49AM (#31558025)
Hey Miguel, wanted to thank you for creating this tutorial. It started my freelancing career and I created great projects based on it. Thank you very much!
Re:Flask Mega-Tutorial (2017) by kadenwolff on Monday May 30, 2022 @11:18AM (#31559944)
Read this tutorial 3 years ago or so, thank you for writing it!
Re:Flask Mega-Tutorial (2017) by tugberkk on Monday May 30, 2022 @06:58AM (#31557682)
Your videos and writings are absolute gem! Thank you!