TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Flask: a micro web framework for Python

114 pointsby iamelgringoabout 15 years ago

11 comments

simonwabout 15 years ago
Some really interesting ideas here, especially coming at it from a Django background.<p>Flask embraces thread locals - Django tends to pretend they aren't necessary at the user level, even though there are a few of them lurking in the core framework. Flask's request object is thread-safe global, and Flask encourages you to put your own per-request global instances (such as a database connection which is opened at the beginning of the request and closed at the end) on the special flask.g object. I've always disliked this kind of approach because it makes it hard to run your code outside of the context of a web request (e.g. in a cron script), but Flask deals with that by providing a clever test_request_context method:<p><pre><code> from flask import request with app.test_request_context('/hello', method='POST'): # now you can do something with the request until the # end of the with block, such as basic assertions: assert request.path == '/hello' assert request.method == 'POST' </code></pre> Using the with statement here is very smart - Flask seems to get a lot of mileage out of both context managers and decorators.<p>I'm looking forward to seeing how Flask shapes up - it feels like a very modern attempt at a Python micro-framework, with some pleasantly unconventional ideas.
评论 #1260699 未加载
chairfaceabout 15 years ago
I think this was an April Fool's joke: <a href="http://lucumr.pocoo.org/2010/4/3/april-1st-post-mortem" rel="nofollow">http://lucumr.pocoo.org/2010/4/3/april-1st-post-mortem</a><p>edit: In response to the downvotes - it appears that it was an April Fool's joke, but because of the response he got, Armin decided to try it out for real. Yeesh.
sumeetaabout 15 years ago
Since it’s by the same author, this is probably inspired by or related to Armin’s April Fools’ Python micro web framework:<p>Denied: Python Micro-Framework (<a href="http://news.ycombinator.com/item?id=1237412" rel="nofollow">http://news.ycombinator.com/item?id=1237412</a>)<p>April 1st Post Mortem (<a href="http://news.ycombinator.com/item?id=1239438" rel="nofollow">http://news.ycombinator.com/item?id=1239438</a>)
paulsmithabout 15 years ago
If anyone is trying to follow along with the Quickstart, a simple virtualenv + easy_install Flask didn't work for me -- I needed to install Werkzeug tip (easy_install Werkzeug==dev) and install Jinja2 from tip as well (hg clone <a href="http://dev.pocoo.org/hg/jinja2-main" rel="nofollow">http://dev.pocoo.org/hg/jinja2-main</a> jinja2).
samratjpabout 15 years ago
Could this be Python's Sinatra?
评论 #1259433 未加载
busterabout 15 years ago
Also: Python web "framework" in 705 loc: <a href="http://github.com/breily/juno" rel="nofollow">http://github.com/breily/juno</a>
xoxabout 15 years ago
Will it work on Google App Engine?
评论 #1259414 未加载
tocommentabout 15 years ago
Is this better than bottle?
digispaghettiabout 15 years ago
Reading this the documentation is really easy to read and understand. Doesn't seem to have the restrictions of Django, you could build small distributed apps that communicate over sockets or REST.<p>Would also hope to see good support with document databases like mongodb.
anethabout 15 years ago
Not that Python needs more web frameworks (<a href="http://wiki.python.org/moin/WebFrameworks" rel="nofollow">http://wiki.python.org/moin/WebFrameworks</a>), but it's good to see Python use its new poor-man's equivalent to Ruby's block syntax.
评论 #1261170 未加载
mkramlichabout 15 years ago
Not addressing Flask directly but the article made me think of something about small web frameworks. It strikes me as easier to come up with a new "big" web framework than it is with a new small one. Because after a certain point, its hard to come up with a framework where a Hello World web app can be expressed with any fewer lines of code. It's always possible to make a more verbose web app, it may be impossible past a certain point to make one more concise.<p>Perhaps Flash's angle could be not to shrink the minimum LOC needed, but to deliver more features per app LOC.