News for hackers. Stuff that matters.
Re:The Flask Mega-Tutorial (2012) by ryannevius on Monday November 19, 2018 @02:47AM (#18484762)
Miguel's Mega-Tutorial was invaluable to me when I was learning Flask circa 2011-2012. It's a great resource.

That said, IMHO, if you're going to implement a simple CRUD app in Python, you may as well just use Django. Django includes all of the "batteries" for handling forms, authentication, databases (the ORM), etc. right out of the box. I think Flask has its place; but when it becomes a simple reimplementation of Django, I'm not sure I see the point.

Re:The Flask Mega-Tutorial (2012) by drcongo on Monday November 19, 2018 @06:45AM (#18485724)
Personally I much prefer the lack of magic in Flask and would far rather make a crud app in Flask than Django. Whenever I have to use Django I'm endlessly frustrated by the fact that everything is so abstracted and there's so much magic that most of my stack traces show only ~30 lines of Django internals and none of my own code.

Another (old but still excellent) resource for anyone learning Flask: http://mattupstate.com/blog/how-i-structure-my-flask-applica...

Re:The Flask Mega-Tutorial (2012) by diminoten on Monday November 19, 2018 @12:53PM (#18488210)
Totally agree, Django's ORM is fantastic, and everything else is fine. Combine Django with Django REST Framework and you've got a great way to build an API in no time flat.

For projects that don't require an ORM, or work with databases that Django doesn't support, I'm not as big a fan of Django, however.

There's an idea floating around on my team right now that literally all of our projects, even non-webapps, should be Django (I got questions about my use of -m recently, was told a "management command" would have been better), so I'm sensitive to this "just use Django" advice, maybe.

Re:The Flask Mega-Tutorial (2012) by geezerjay on Monday November 19, 2018 @03:57AM (#18484993)
If people want "batteries included" solutions then nowadays they are better off going with spring or ASP.NET Core.
Re:The Flask Mega-Tutorial (2012) by collyw on Monday November 19, 2018 @04:40AM (#18485158)
Why? I use Django and its pretty good.
Re:The Flask Mega-Tutorial (2012) by jimnotgym on Monday November 19, 2018 @06:12PM (#18490576)
I wish you had written a more detailed answer. I have to say I am really impressed by ASP.NET Core MVC on first look. I would love it if you had suggested something like the OP's Mega Tutorial for .net core. Then we could all have taken a look, rather than just taking your word for it.
Re:The Flask Mega-Tutorial (2012) by ksahin on Monday November 19, 2018 @04:07AM (#18485031)
This Github project "Flask-base" is great to start a flask project : https://github.com/hack4impact/flask-base Lots of things are included, user management/permissions / redis / SQLAlchemy ...
Re:The Flask Mega-Tutorial (2012) by jimnotgym on Monday November 19, 2018 @06:01PM (#18490512)
This is really good! I must have a play...
Re:The Flask Mega-Tutorial (2012) by diminoten on Monday November 19, 2018 @01:18AM (#18484518)
The link says it's from December 5th, 2017, so not 2012. Probably worth changing in the title here on HN.

https://www.kickstarter.com/projects/1124925856/the-new-and-...

Thanks 'windexh8er for mentioning something in the first place.

Re:The Flask Mega-Tutorial (2012) by guitarbill on Sunday November 18, 2018 @11:48PM (#18484284)
one thing i always see glossed over is using application factories [0]. they are a bit harder to grok initially, since you have to hook your dependencies up via the factory, but they really help with testing/deploryment and scaling up flask apps. it's so much easier to do it at the start than to try and retro-fit it. similarly, blueprints from day 1 also make sense.

[0] http://flask.pocoo.org/docs/1.0/patterns/appfactories/

Re:The Flask Mega-Tutorial (2012) by geezerjay on Monday November 19, 2018 @02:35AM (#18484721)
> one thing i always see glossed over is using application factories [0]. they are a bit harder to grok initially,

IMHO what makes app factories hard to grok is the poor documentation and examples/tutorials on the topic. The official docs mention app factories are great but then don't include any clear example on how they could be used with routes. They do include examples that don't use app factories, thus that's what newbies use to get up and running, and afterwards keep on using because it works.

Re:The Flask Mega-Tutorial (2012) by diminoten on Monday November 19, 2018 @01:16AM (#18484513)
I've been using Flask for a few years now, and the other day had to whip up a small app for a task at work. This is the first app I've used Blueprints and Application Factories, so I'm looking forward to better understanding their payoff in the future.
Re:The Flask Mega-Tutorial (2012) by cirgue on Monday November 19, 2018 @09:09AM (#18486477)
Do you know of a good side-by-side comparison of a simple app built with blueprints versus one without? I am still trying to wrap my head around the problem that they solve.
Re:The Flask Mega-Tutorial (2012) by guitarbill on Monday November 19, 2018 @12:58PM (#18488255)
thing is, a simple app won't show you the benefits. blueprints are basically modules, and allow you to compose a big flask app from multiple blueprints. so as your app grows, you can add new features sanely (especially routing). a nice side-effect is having to think as features being correctly separated.

initially, it's only a bit more effort, but as you scale it'll stop e.g. your views.py getting out of control, without resorting to hackery.

again, it can be hard to do retro-actively, and once you realize you need it, the codebase is usually pretty bad. so i just do it from the start, as the extra effort is small then.

(best practices prevent team members with less experience from committing attrocities and give them a good foundation to copy from)

Re:The Flask Mega-Tutorial (2012) by reacharavindh on Monday November 19, 2018 @02:48AM (#18484764)
Those interested in Flask may be interested in Quart (Flask compatible, but faster because of Asyncio)

https://pgjones.gitlab.io/quart/index.html

Re:The Flask Mega-Tutorial (2012) by ergo14 on Monday November 19, 2018 @06:56AM (#18485772)
Asyncio does NOT make applications faster, especially if you are CPU bound.
Re:The Flask Mega-Tutorial (2012) by reacharavindh on Tuesday November 20, 2018 @07:31PM (#18499189)
But, most web applications are IO bound... dashboards, CRUD apps, simple wrapped up API calls etc.

For a truly CPU bound application, you ought to be looking at something other than Python IMHO.

Re:The Flask Mega-Tutorial (2012) by jimnotgym on Monday November 19, 2018 @06:08PM (#18490551)
I feel like I should mention Miguel's book.

It builds a similar kind of application. I would say it is complimentary. It is not as deep as, say, the Goat Book is on Django.

https://flaskbook.com/

Re:The Flask Mega-Tutorial (2012) by whitehouse3 on Monday November 19, 2018 @06:40AM (#18485694)
I maintain a mid-sized (5000 LOC) Flask web app. Miguel’s mega-tutorial is required reading for new dev’s coming onboard the project.
Re:The Flask Mega-Tutorial (2012) by bl4ckm0r3 on Monday November 19, 2018 @11:18AM (#18487434)
This was such a life changer when learning flask! I wish all the techs had such a complete and well explained tutorial for beginners.
Re:The Flask Mega-Tutorial (2012) by Beefin on Monday November 19, 2018 @06:02AM (#18485532)
This is the tutorial that first taught me flask and the reason it’s my preferred backend framework today. Go Miguel!
Re:The Flask Mega-Tutorial (2012) by mjsaah on Sunday November 18, 2018 @09:08PM (#18483723)
I've been using this as a reference while building a webapp with flask. It's been treating me very well.
Re:The Flask Mega-Tutorial (2012) by windexh8er on Sunday November 18, 2018 @11:04PM (#18484157)
It's also not from 2012. Miguel did a major rewrite last year that was crowd funded. This is the updated guide.
Re:The Flask Mega-Tutorial (2012) by suprfnk on Monday November 19, 2018 @02:47AM (#18484759)
Yes, this should have a (2017) tag, not (2012).
Re:The Flask Mega-Tutorial (2012) by agumonkey on Monday November 19, 2018 @04:48AM (#18485188)
Interesting I forgot he did that.
Re:The Flask Mega-Tutorial (2012) by hkt on Monday November 19, 2018 @04:42AM (#18485165)
Me too, it's great. Very well written and easy to follow.
Re:The Flask Mega-Tutorial (2012) by imeron on Monday November 19, 2018 @02:13AM (#18484648)
Is this mega tutorial format better than the current trend of video courses? Do you guys have a preference?
Re:The Flask Mega-Tutorial (2012) by suprfnk on Monday November 19, 2018 @02:45AM (#18484748)
I really dislike video courses. There is, usually, no good way to quickly scan for the important parts.

If there is stuff you already know, skipping forward minutes will keep you wondering whether you have missed something important. With text you can scan through unimportant parts relatively easy, while knowing you didn't miss something important.

Re:The Flask Mega-Tutorial (2012) by geezerjay on Monday November 19, 2018 @02:30AM (#18484705)
Mega tutorials are a very poor format because they don't cover each topic in a self-contained manner, nor they provide a minimum working example to test.

However, they are way better than any video course.

Re:The Flask Mega-Tutorial (2012) by zabana on Monday November 19, 2018 @04:14AM (#18485059)
I guess it depends on the type of person you are and how you learn best. In my case for example, I learn better by coding while following a video than when I have read through a massive blog post (Which involves a lot of copying and pasting). That said, text format is great in book form because you can easily reference a concept without having to scroll through an endless page. The only downside with books is you have to wait longer for the content to be updated. Just my 2 cents.
Re:The Flask Mega-Tutorial (2012) by chauhankiran on Monday November 19, 2018 @03:43AM (#18484948)
Anybody know something similar on Node.js, Express or MEAN?
Re:The Flask Mega-Tutorial (2012) by thekdude on Monday November 19, 2018 @09:19AM (#18486531)
https://devcenter.heroku.com/articles/mean-apps-restful-api

This tutorial helped me get started when I needed to build a MEAN webapp for a project