Bottle 0.8 released (Micro Web Framework)

15 comments · 85% upvoted · source · other discussions

comments

directrix1

How many hundreds of micro web frameworks do we have for Python now?

EDIT: Not saying anything about this particular one, but why do so many people try their hand at building a micro web framework?

opi

It's a learning experience.

mitsuhiko

but why do so many people try their hand at building a micro web framework?

Because a basic (even if not passing any tests) WSGI implementation is very simple and everyone wants to has one on its own which is slightly different to others. I'm one of those offenders with my Werkzeug library and also with a Framework on top of it.

Variety Is The Spice Of Life they say.

defnull [OP]

I never published the link but there are t-shirts available for some time now: http://bottle.spreadshirt.de/

If you don't want to buy there, you can get the logo as a vector image and print your own. Just ask :)

blondin

...really stop calling them micro. i saw what flask has to give last time, and i wouldn't call it a micro web framework.

opi

It is, by far, my fav. web framework.

pwang99

Nifty! I tried it out a couple of months ago to front-end a little Redis-based prototype, and it worked well. Unfortunately its launcher front-end does not run a threaded TCP server by default, and I discovered that only after my live demo... :)

High2plus3

I haven't had the chance to try out Bottle or Flask, but they look very similar. Does anyone have experience with them? Maybe some good/bad of each, or is it really just a toss up?

mitsuhiko

I'm biased towards Flask because I'm the author, but here the big differences between the two:

  • bottle is a single file and implements everything itself
  • it does not depend on anything but the stdlib to accomplish what it does

On the opposite there is Flask:

  • based on Werkzeug and Jinja2 for WSGI implementation and the templating. Due to that it's also more powerful in that regard (Werkzeug for instance parses all HTTP headers for you, Jinja2 has tons of template helpers etc.) These libraries are also used on a couple of websites already, despite the young nature of Flask which came afterwards.
  • Flask has many extensions by now for OAuth, OpenID, Scripting, easier file upload handling etc, SQLAlchemy and more.
  • I think the main reason why people use Flask is the documentation though which I'm pretty proud of: http://flask.pocoo.org/docs/
3Dayo

You have good reason to be proud of Flask doc; it is fantastic! and I for one owe you a debt of gratitude.

MercurialAlchemist

Side question - I was briefly looking at the Flask documentation earlier. Is there a way to not put routing in the controllers? I like the way having a separate url.py-equivalent gives you the flexibility to reuse controllers in another context with different routes.

mitsuhiko

Sure. If you are looking for something similar to Django, this part of the documentation might be what you are looking for: http://flask.pocoo.org/docs/patterns/lazyloading/#converting-to-centralized-url-map

MercurialAlchemist

Ooooh, shiny. Thank you sir, have an upvote.

defnull [OP]

mitsuhiko sums it up quite well. I'd just add these points:

  • Bottle supports Python 3 (even if some aspects of the WSGI standard are still vague in terms of python 3)
  • The build-in template engine is quite unique for it allows you to use python for the template logic and is one of the fastest template engines available. No need to learn a new template language here.
  • Bottle comes with preconfigured adapters for several third party template engines (mako, jinja2, cheetah) and WSGI servers (cgi, flup.fcgi, cherrypy, paste, fapws3, tornado, Google App Engine, twisted, diesel, gunicorn, eventlet, gevent, rocket) and makes it easy to switch. If the build-ins don't match your needs, you can replace them without hacking the framework. Bottle grows with your project.

Of cause I am biased, too ;)

defnull [OP]
[deleted]

Thanks for putting your time and effort into the project! It's awesome and I can't wait to use it.

[deleted]

I use bottle to add REST apis to control my eventlet daemons - it's enough to spice up some functions with route(), call eventlet.wsgi.server with bottle.default_app() and profit. Thank you for bottle!

That said, I choose flask for tasks more resembling "true" web programming. I trust werkzeug's wsgi implementation more, plus I get cool ajax debugger, sessions, easy jinja templating and stuff.