top | item 31556522

Flask Mega-Tutorial (2017)

234 points| memorable | 3 years ago |blog.miguelgrinberg.com | reply

87 comments

order
[+] miguelgrinberg|3 years ago|reply
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.

[+] kyle_morris_|3 years ago|reply
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!
[+] iknownothow|3 years ago|reply
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?
[+] alejoar|3 years ago|reply
Hey Miguel, I got my first web developer job right after reading you Flask Web Development book in the summer of 2015. Thanks!
[+] cushychicken|3 years ago|reply
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!

[+] john-radio|3 years ago|reply
Your work really got me off the ground with web dev, man. Thank you.
[+] hkt|3 years ago|reply
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!
[+] manugarri|3 years ago|reply
Your mega post made me learn web development almost a decade ago!, thanks a lot!
[+] tsumnia|3 years ago|reply
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.
[+] agumonkey|3 years ago|reply
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

[+] teruakohatu|3 years ago|reply
Is flask-admin worth using? Or any other auto-admin type libraries?
[+] mgraupner|3 years ago|reply
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!
[+] kadenwolff|3 years ago|reply
Read this tutorial 3 years ago or so, thank you for writing it!
[+] tugberkk|3 years ago|reply
Your videos and writings are absolute gem! Thank you!
[+] sireat|3 years ago|reply
I can second that Miguel's tutorial is quite nice and sufficient to build Flask apps.

Thanks to Miguel (and also official Flask docs) I have some Flask Apps running non stop for a few years by now.

Flask is extremely easy to write in regards that the mental model is easy to follow. Sure there is magic there but the abstractions seem "non-leaky". By contrast I can't get into Django because it seems too much magic.

The worst part of using Python for back end was deployment. Setting up WSGI server to host Python apps was a bit of a pain.

https://flask.palletsprojects.com/en/2.1.x/deploying/

I think I went with Gunicorn but there was a bit of learning curve there. I am not even sure if that was the right choice

[+] gosukiwi|3 years ago|reply
Coming from Rails, I appreciate Django's less-magical approach. I admit it has some silly limitations though, like not being able to call methods with arguments in templates, and the whole mixin view generic classes, just to name a few

That being said, Django is great, and so is Python :)

[+] pil0u|3 years ago|reply
This is how I started my journey with web development.

I was a Data Scientist and I superficially used Flask to build an internal matching tool between internal products and competitors product (after an ML model). Then I started the Mega-Tutorial to build a small app to track our foosball matches and run a team tournament. Eventually, I wanted to accelerate my learning and joined a bootcamp (Le Wagon) where I learned Ruby on Rails from scratch. My Flask introduction with this tutorial was really helpful to understand things on almost all layers.

I always recommend this tutorial to people who come from Python and want a sneak peak to web development. I am very grateful for Miguel's work and for sharing it.

[+] ryannevius|3 years ago|reply
Miguel has updated this guide (available for purchase). In my opinion, it's worth every penny as a starting point into building larger Flask apps, but does include some material that isn't optimized for production-ready Flask apps (e.g. the chapters on authentication).
[+] divbzero|3 years ago|reply
What part of the authentication material isn’t optimized for production and what adjustments would you recommend?
[+] marmakoide|3 years ago|reply
I learned to use Flask with this tutorial, which complemented the already good Flask documentation. This allowed me to spin-up web interfaces to make monitors, remote control panels and so on very easily. Than you very much Miguel, it was a great gift.
[+] parham|3 years ago|reply
This was my go to for learning Flask, I wish I never found it. Flask has a very niche use case in my opinion and if you need something to scale (in terms of code complexity) Flask is the absolute worst decision you can make.

Try Django instead. If you read my comment history you'll see that I learnt this the hard way.

[+] Zr40|3 years ago|reply
In my experience it's quite the opposite. We use Flask for a large-scale webapp in production quite successfully and it's enabled us to reduce application complexity significantly.
[+] nicbou|3 years ago|reply
That was also my experience. I find flask to fill a small gap between SimpleHTTPServer and Django.
[+] alexcnwy|3 years ago|reply
Totally disagree.

Flask is scaling really well for us and it’s flexibility is far better than Django’s opinionated approach.

[+] ibz|3 years ago|reply
I find it to be quite the opposite actually.

While you get up and running faster with Django, in the long run you spend more time fighting it, whereas with Flask you only spend time on stuff that you actually need.

[+] nabla9|3 years ago|reply
After reading your comment history and searching it, it seems to me that you never learned to use Flask. Jumping into new project and learning a framework at the same time means that you may have to restructure everything after you have learned it.

That's my impression at least.

[+] sgt|3 years ago|reply
For the items covered in this tutorial, I would rather recommend Django. Better documented and arguably more suited to the task. For an API alone e.g. along with an SPA I would consider FastAPI.
[+] caspii|3 years ago|reply
I learned Flask using this tutorial for a toy project. 4 years later that project has become my main source of income.

Flask is fantastic and I would recommend it to anyone starting out developing webapps.

[+] godmode2019|3 years ago|reply
Flask is easily the best python web framework. Many years ago a learnt flask from this tutorial

I built a json ui for my flask apps the other day - Jsonify - https://github.com/xzava/jsonify

While I am a flask fan, a lot of good things can be said about fastapi.

[+] trashm3|3 years ago|reply
Miguel is a great teacher; it's difficult to find proper (up to date!) text-based tutorials in this era. I will also give a shoutout to his recent React Mega-Tutorial, which I've been learning and using his tutorial as one of my sources for learning React.

I did his flask tutorial a year + ago before I started learning react. I'd love to see the workflow for developing a backend Flask API first (without Jinja/render_template). It seems less straight-forward than FastAPI which I am using because I think it's simpler to develop APIs first (ala the name)

[+] drcongo|3 years ago|reply
I've recommended this tutorial for years to people wanting to learn Python for the web. It's really well done.
[+] 4dregress|3 years ago|reply
This is gold! He also has a great tutorial explaining how to use celery with Flask!
[+] Zababa|3 years ago|reply
Is there anything like this but for express? Trying to piece together 10 libraries and 20 medium articles is always a bit of a pain.
[+] Tyrannas|3 years ago|reply
Step 1: pip install fastapi /s
[+] wiktorcie|3 years ago|reply
fastapi is valuable and useful tech. But it's also very over hyped with all the it's fanatics trying to throw it at every problem. Simple admin dashboard for few dozen users? FASTAPI. Backend for a mobile app? FASTAPI.

There is more useful and battle tested solutions out there for flask than fastapi (due to it's obvious time in the market, but still).

It's also interesting to check number of github issues for both frameworks (14 vs >1k).

Nonetheless fastapi is great.

[+] jyriand|3 years ago|reply
Care to explain?
[+] nagestri|3 years ago|reply
Awesome. This is why I read this board.
[+] nchudleigh|3 years ago|reply
This was a big part of my start into flask. Great tutorial.
[+] marban|3 years ago|reply
I'm somewhat of a Flask pro but have struggled to find a good entry on how to use it as a backend for a native iOS app (for someone who completely missed the Swift train). I guess it starts with migrating to Fastapi?
[+] arinlen|3 years ago|reply
Speaking of backend development, recently I gave Jooby[1] a try after discovering it was one of the world's top performer in Tech Empower's web framework benchmark[2].

Surprisingly enough, it's terribly easy to put together a REST API with Jooby. I was expecting a lot of arcane tricks to set things up, but it's one of the less.verbose frameworks out there.

I wonder why it's adoption rate is so low.

[1] https://jooby.io/

[2] https://www.techempower.com/benchmarks/

[+] neurostimulant|3 years ago|reply
Not using Flask, but I've been using Django as backend for various iOS apps over the years. My recipe is just a REST API library + Django OAuth2 Provider. I imagine if I were to use Flask, I'll do the same thing: implementing the REST API and gate it using OAuth2. Plenty of library in iOS side that make hooking up with OAuth2 relatively easy.
[+] darkstar_16|3 years ago|reply
Why fastapi, though ? What's missing in Flask if you just want to learn iOS programming ?
[+] rhodysurf|3 years ago|reply
What is flask missing? FastAPI has swagger and open api stuff but it’s not like it’s required or necessary most of the time. I use my basic flask server as the most dead simple rest API backend for my iOS apps without any issues
[+] mgraupner|3 years ago|reply
As others have said: What has one to do with the other? As a Flask pro you probably know that you can create great APIs with it. And iOS apps can consume them.
[+] aiibe|3 years ago|reply
My first web programming tutorial !