Hacker News new | past | comments | ask | show | jobs | submit login
A small fast and cute web framework in Python. (bottlepy.org)
66 points by kghose on May 26, 2012 | hide | past | favorite | 37 comments



Although I've been working with django daily for about the past six months, I used bottle for a small stand-alone 'desktop-like' application.

I needed an easy, quick way to take roll call of a large group of people. We have a laptop with a projector but no internet access where the meeting occurs, so it had to be able to live on a Windows machine without network access. Bottle allowed me to pull together something in about five hours that uses sqlite for local storage of all of the participants names and whether they are present/absent and any notes. Previously, I was doing this on an inherited excel spreadsheet and it was very difficult for anyone else to read their name or any information. Now, it's a very simple HTML page with very large font that can be read from the back of the room.

So, thank you bottle! I was able to develop on Linux and fairly painlessly deploy it to the Windows laptop, and it worked the first time. (That was scary... Rarely happens to me.)


I'm curious, how did you justify the return on investment of developing this? In most business situations, "Use Zoom to make the font bigger" would have been the boss reply.

I almost always have to seed Version 1 as a stealth project or weekend project. Version 2 is more likely to be approved once it has been shown useful.


Ah, I should mention that this is for a volunteer non-profit group. They are/were falling into the 'spreadsheet as a database' trap, so this is the first visible step to move off of that and onto something manageable.

The next stage is to get a slightly more comprehensive site going which will keep track of contact information, attendance history, etc.


Is this code that you can put online somewhere? This kind of thing would a) likely be really handy for lots of people and b) is the kind of thing I'd like to be able to make myself (using browser as a readymade UI), so having an existing reference would be helpful.


Thanks for the interest! I've finally sort of figured out how to use github and put it here: http://github.com/skrubly/rollcaller


Thanks for putting it up. I'll have a play with it!


People interested in frameworks should read bottle's code. It has a neat feature where the request handling is built by sub classing exceptions. This allows request processing to terminate at any point by simply raising the handler. There is a global try/except that then renders the result.

This mechanism is quite good for ensuring every request proper gets a response, though it also allows dodgy exception handling to interfere with processing. A discussion on the merits of exceptions themselves is beyond the scope of this comment. :)


The Play framework (java) also does this:

https://github.com/playframework/play/blob/master/framework/...

See "renderTemplate(String templateName, Map<String,Object> args)" for a good example.


I noticed that too. A truly clever hack. (I mean hack in a good way.)



Bottle is great, not sure if this is really news though?


Apparently no one has submitted the page before. I love bottle. I switched from RoR and never looked back.

Of course I just use it for tiny basically desktop apps, where I just wanted to use the browser as an interface to avoid writing UI code.



Hmm. Shouldn't HN detect dupes and just upvote the orig? Odd.


It's also almost a year ago. It only does the dupe collapsing when within a certain timeframe.


Syntactic differences in the URLs stump dupe detection:

http://bottlepy.org/docs/dev/ vs http://bottlepy.org/docs/dev/index.html


news to me.


I've used it for a couple of projects and did a presentation on it at pyAtl this past March. Nice framework, easy to learn, simple to deploy, has adapters for many of the potential front end servers. If you want a copy of the presentation on the project, I posted it in the presentations area on my blog (marginhound).


Forgot to add - one of the really nice things about using a microframework is that it is easy to assemble a "best of breed" solution using libraries from other frameworks.


If you like bottle but find yourself needing to write Ruby, check out Sinatra.


+1 Sinatra is amazing convenient to use. In the last month I have written two REST style web services for a customer in Sinatra. I sometimes also use Sinatra instead of Rails for for simpler web apps.

That said I installed Bottle and played with it - looks nice!


At the top of the website, in very small text:

    Warning: This is a preview for Bottle-0.11.dev, which is not released yet. Switch to the latest stable release?
Just something to be aware of.


Thanks for the nice feedback :) I am defnull, the author of Bottle. Any questions?


Bottle vs Flask, who will win?


Flask has a bigger dev team, but Bottle is a nicer, more elegant micro-framework. From what I can see, the design of Flask can be broken down into 2 phases. The first phase is essentially like bottle. The second phase added class views and the likes. And it became inelegant and verbose.

If bottle has something like Flask's Blueprint, which facilitates the management of larger projects, bottle will clearly win as a micro-framework.

In the end, who is the winner really boils down to how much love a framework is given to by its founder. Web.py started a generation of nice frameworks, but I think the person behind it didn't put a lot of effort in pushing it forward, and eventually, it just stopped progressing.


Bottle is older than Flask still the latter is far more popular, has more features, is better documented and has a bigger community. It is really not a question of who will win but who has won.


Bottle supports Python 3 (as does CherryPy, Pyramid, and Tornado), while Flask currently doesn't. Depending on project requirements, this may or may not be important.


Werkzeug must support Python 3 before Flask can, and Armin has discussed Python 3 support here on HN before (and there's now a FAQ about it).


I hope they will continue to coexist. Competition is great. I personally prefer Flask, mostly because I built my own little framework on top of Werkzeug before and know the code quite well. Also, I'm not a huge fan of the single-file approach, but this is just my personal preference.


How big do your projects get (by LoC) in a single file in Flask? Have you ever looked into blueprints[1]?

[1] http://flask.pocoo.org/docs/blueprints/


Sorry, I wasn't clear about this. I meant the single-file approach of Bottle.


I love he fact that we have so many options. I myself am writing a small event driven web framework and should be out by the end of summer.


I feel like Flask is node.js of python web frameworks. I guess some people just like shiny/new/popular things.


Why must there be a winner?


I think Flask is a bit better known and tested these days.

One man's opinion (based on experience).


I like the tabs on the side, that's pretty cool. It would be really great on longer webpages where the user is doing even more scrolling.

cool stuff, man.


Is it wrong that I use web.py? Should I feel dirty and start using bottle instead? :P




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: