New Werkzeug and Flask Releases
lucumr.pocoo.org
lucumr.pocoo.org
There is a good reason for why Werkzeug (which Flask is based on) is 15000 lines of code.
Repeating his "I had to make X big to support all of wsgi/http so anyone who made a similar framework but much smaller has made it incomplete or too succint and clever in a bad way" is not evidence.
You say:
>bottle's smaller size means either the implementation is incomplete or the implementation is too clever or both.
That's a statement of fact (actually a dichotomy of facts). What's the evidence to support these are the only two possible options?
The mere fact that Armin had to make Werkzeug bigger "owing to complexities of wsgi/http" is not proof.
To take it as proof is to assume his coding (and understanding of wsgi/http) as the golden standard by which the Bottle developer should be measured.
Who said this is the case? For one, it took him a year after Bottle to support Python 3, so he might not be that focused, anyway.
My problem is that, the way he and you say it, "incomplete" implies broken or lacking, whereas "too clever" implies fancy tricky code that's too succinct for it's own good.
How about the third option that he needlessly convoluted Werkzeug to work around wsgi/http edge cases that no one really faces, whereas Bottle has been pragmatic about it?
Or the fourth option, that Werkzeug is needlessly verbose, whereas Bottle is not "too clever" but just as clever as needed?
I've tried both frameworks, and looked at the code for both, and I'm of the opposite opinion.
Yours is not a very suggestion. It presupposes what is asked to provide evidence for. That's called a circular argument.
This is a really disingenuous generalization. If it's not Flask, it's messy and confusing? Telling every framework developer who's not the author of this one library that their code is crap not only isn't a great way to be taken seriously, it's wrong and just kind of mean.
I dunno, I've recently started getting into it and "convoluted" is one word that has occurred to me more than once. Handlers vs signals, application and request context, context locals, local proxies, etc.. Probably there's a good reason for all these and the docs make a decent attempt to lay them out but overall my unscientific first impression is that it's not exactly a pinnacle of simplicity.
Those are just different names for the same thing. Maybe the docs are a bit too in-your-face with the contexts but I rather expose people to it early to avoid issues down the line.
Django for instance does not have equivalents for application and request contexts and the end result is that people often write thread unsafe code and you can only have one application per Python interpreter. Flask does not have those restrictions. You can have as many Flask applications living side by side. And that is possible because of the contexts.
Global proxies to local state are another beast entirely. They are "easy" in that they remove the need to pass application and request objects through every called function, but they are not "simple" -- they rely on intimate details and peculiarities of Python's module and import system, and its capacity for thread-local state, not to mention Python's robust context unwinding features in the case of exceptions. Overuse of context-proxies leads to the same software engineering challenges as overuse of globals, in that it becomes difficult to reason about the calling semantics of functions which rely on context state being present, or mutate context state through proxies. For example, in order to test a view function, you will at a minimum need to set up an application context, but also need to set up any custom context your app relies on. It's not always obvious how to do this, leading to documentation [1] that I notice has already been confusing people on the mailing list.
So I wouldn't conflate the two mechanisms. Application- and request-local context is a pre-requisite for multi-tenant applications and a conceptual simplification. Module-level proxies are a cute trick that makes programmers' lives easier, but undoubtedly creates more convoluted semantics and internal operation.
[1]: http://flask.pocoo.org/docs/testing/#faking-resources-and-co...
Yes, it's not the best solution, but passing things around isn't either.
https://python3wos.appspot.com/ needs an update. :)
The Flask page still recommends holding back... (http://flask.pocoo.org/docs/python3/)
You should stick with 2.7 As mentioned in your linked blog post, porting Flask to Python 3 wasn't the issue. The issue is the other libraries which you will use to build your web application which aren't on Python 3 yet. You can try to build a unified code base(runs on both 2.7 and 3) http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
If you are writing most of your own code and not using Flask extensions then you could well be fine (unless, like the linked post says, you discover a few months down the line you _do_ need a couple of extensions and they haven't been ported yet!).
Also worth pointing out that lots of other great python libraries now fully support python3 so you can get a lot done with just Flask on its own and those e.g. requests, redis-py, psycopg2, pytz.
Compared to asp.net, its an absolute joy to work with. It makes me not want to grind my face off with a blunt spoon :)
Glad to see some awesome progress with it.
So I ask. How safe is it to use in a real project? Is it a serious project today? Would you recommend Flask to someone who has never done any server side programming?
We (mailgun.com) use it in production, our deployment handles thousands of requests/sec, we have not seen any flask-related issues so far in 2+ years.
You can use pool of flask + twisted powered services behind nginxes:
Nginx ---upstream pool--> twisted.wsgi + thread pool + flask app
Something like that:
After numerous purges (the magic-removal-branch being the biggest) and deprecations over the years since 1.0, Django is IMO pretty magic-free. If you have suggestions of what isn't Pythonic enough, I think the core team would appreciate a ticket on Trac:
https://code.djangoproject.com/newticketThough I think they may have recently replaced this bit of their architecture with Go?
FWIW, I've chosen Flask to power my startup and have no regrets at all. It's a joy to work with and rock solid :)
If you're building a complex web app with it, just be sure to checkout all the Flask extensions so you don't have to reinvent the wheel too much.
"Flask-RESTful was initially developed as an internal project at Twilio, built to power their public and internal APIs" http://flask-restful.readthedocs.org/en/latest/
It's definitely nice to see other responses here that are from people who are, first hand, using Flask in high-traffic live deployments. I'd just be careful about drawing conclusions based on who has it somewhere in their stack without any context.
To be fair to your skepticism, I have probably followed Twilio more than you've had. I seem to remember that they switched to Flask, so I don't think it was technical debt that they had to work around later on. (like it might have been the case with Facebook and PHP)
Let's say that "Twilio uses Flask for their API" answers the question "can it be used in production?" (or "is it a serious project today?"). "Should you use it in production?" is where context matters more.
No, the argument is the same: "Facebook runs on PHP, so PHP must be stable".
Which makes sense. A base technology that holds up with half a billion users, I would call production ready.
As for fast, if you look at the most comprehensive benchmarks, PHP is more or less on par with Ruby/Python for raw speed of simple page serving, but when multiple DB connections are used in a page (which is the most common case for dynamic pages), it leaps far ahead, and reaches Servlet and Go levels of reqs/sec.
Every request to new-ish parts of the Twilio API touches Flask, and it's performed like a champ.
I think flask has a front page that discourages newcomers, as it does not look as serious as Django, and gives the feeling that is it not mature enough, or documented. I tried convincing a new startup to use it and failed for those reasons.
(From the tarball release Download the most recent tarball from the download page.)