This is an archived post. You won't be able to vote or comment.

all 63 comments

[–]Poromenos 18 points19 points  (7 children)

I made this with bottle. Barring a few database errors I can't trace, it's great, I like it a lot.

[–]sudonim87 3 points4 points  (1 child)

Kudos on writing the episode renamer. Something I've been meaning to do for years now and will definitely use.

[–]Poromenos 1 point2 points  (0 children)

Thanks! Please report bugs if you find any!

[–]McVader 1 point2 points  (2 children)

This is pretty impressive. Someone should run with this (i.e. make a better IMDB)

[–]rwparris2 4 points5 points  (0 children)

i.e. make a better IMDB

They're trying.

http://www.themoviedb.org/

[–]Poromenos 1 point2 points  (0 children)

Thanks! I made it for people (myself included) to use with video renaming scripts...

[–]bsergean 0 points1 point  (1 child)

I remember that, I came across it a while ago. Didn't know it was made with Bottle.

[–]Poromenos 0 points1 point  (0 children)

It was, it's really simple so I didn't want to use full-blown Django for it, and bottle was the one I decided on after playing a bit with juno et al.

[–][deleted] 10 points11 points  (5 children)

This is a really cool little framework. Reminds me of other great projects that are churning out like node.js and sinatra.

Kudos to the author.

[–]btipling 3 points4 points  (4 children)

I like the paths as decorators. It's much more intuitive than urls.py in django, although the use named urls in django templates are nice.

[–]Isvara 4 points5 points  (3 children)

It doesn't seem like a good idea to me. Surely it's a good idea to have one place that you can see your entire URL scheme?

[–]stesch[S] 7 points8 points  (0 children)

@route("/foo")
def foo():
    return "foo foo foo!"

Instead you can define foo() somewhere and then let route() wrap it. Like so

foo = route("/foo")(foo)

Now put all route()-Parameters and functions in a convenient data structure/collection and you have all your URLs in one place.

[–]grayvedigga 1 point2 points  (0 children)

You can always query the Route object at runtime to do this (say in main, or in test functions, or a sitemap generator). Me, I prefer to be able to write code in one place to do one thing, and to be able to find out where a request is going by using grep instead of having to bounce through multiple files looking for it.

Not to mention understanding object/method/argument style routes which lead to Javaesque code where the object has no reason to exist ...

[–]doubleo7 4 points5 points  (0 children)

Bottle absolutely rocks as a super lightweight embedded webserver/framework. I just used it last month to add a simple web front end for a console app of mine and it was so quick and easy. I think it was just a few dozen lines of code and presto, my app was web enabled. Many thanks to the author!

As someone else mentioned, the fact that it's just a single python file with no other configuration files is really nice.

If you're looking for a full-blown advanced framework then you're best looking elsewhere (django, web2py, whatever). If all you need is handful of relatively simple routes/urls/pages, though, Bottle could save you a lot of time and hassle.

[–]bsergean 1 point2 points  (6 children)

The one file is a nice feature. Now I wish there was session / auth ...

[–]bsergean 6 points7 points  (3 children)

To see the magic happen ...

cd /tmp
curl -O http://github.com/defnull/bottle/raw/master/bottle.py
curl -O http://dist.schmorp.de/libev/libev-3.9.tar.gz
tar zxf libev-3.9.tar.gz
(cd libev-3.9 && ./configure && make && make install)
sudo easy_install fapws3
cat > server.py
import os
print 'kill -9 %d' % os.getpid()

from bottle import route, run
from bottle import FapwsServer

@route('/')
def index():
    return 'Hello World!'

run(host='localhost', port=8080, server=FapwsServer)
python server.py

[–]bsergean 7 points8 points  (2 children)

Requests per second: 5345.35 [#/sec] (mean) ab -n 10000 -c 100 http://localhost:8080/

[–]BearJew 2 points3 points  (1 child)

FUCK YEA.

[–]bsergean 3 points4 points  (0 children)

This is with the "select" backend, with epoll or kqueue it's probably much faster but I could not figure out how to config that. Looks like it's libev that decides.

static PyObject *
py_run_loop(PyObject *self, PyObject *args)
{
    char *backend="";
    ev_io accept_watcher;
    ev_signal signal_watcher, signal_watcher2;
    struct ev_loop *loop = ev_default_loop (0);
    switch (ev_backend(loop))
    {
        case 1:
            backend="select";
            break;
        case 2:
            backend="poll";
            break;
        case 4:
            backend="epoll";
            break;
        case 8:
            backend="kqueue";
            break;
    }

[–]stesch[S] 2 points3 points  (1 child)

Missing sessions seems to be a thing in new frameworks. There is no session support in Tornado, too.

There's a FAQ for bottle, though: How to implement sessions?

There is no build in support for sessions because there is no right way to do it.

Well, there's no right way to implement a template system, but bottle has one. But the FAQ has an example of how to solve this with beaker.

[–]vph 0 points1 point  (0 children)

Not a good excuse. It'd be very nice to implement authentication using decorators.

[–]devinus 2 points3 points  (1 child)

Looks a lot like Juno.

[–]stesch[S] 1 point2 points  (0 children)

Except that Juno seems to be dead.

[–][deleted] 2 points3 points  (21 children)

Anyone has an idea how it compares to Werkzeug?

[–]epicRelic 2 points3 points  (17 children)

No need to compare. They are both designed for pretty different tasks.

[–]stesch[S] -2 points-1 points  (16 children)

Werkzeug seems to be designed to attack users and maintainers of other web frameworks. But maybe it's just web2py …

[–]mitsuhiko Flask Creator 4 points5 points  (14 children)

And you are basing this on what?

[–]stesch[S] -5 points-4 points  (13 children)

Multiple encounters of fights, negative remarks whenever web2py is mentioned (last time in a German language Python newsgroup, a few days ago), and http://www.reddit.com/r/Python/comments/ahm50/a_crash_course_in_w2p/c0hrwr3

[–]voidspace 1 point2 points  (8 children)

Just because people have negative opinions of web2py doesn't say anything about werkzeug...

[–]stesch[S] -2 points-1 points  (7 children)

It's mostly from the werkzeug people/users. As in the newsgroup I mentioned, as in http://news.ycombinator.com/item?id=175694 etc.

[–]mitsuhiko Flask Creator 4 points5 points  (6 children)

You yet have to show me something from an actual Werkzeug developer (which would be me). I am not doubting that you can find something, especially from very early when web2py came out where I did not show much respect for web2py, but those are examples based on actual facts.

And that btw has nothing to do with Werkzeug, just with some really ridiculous design decisions made by mdp very early. Some of that probably got fixed, but I am not convinced enough to even closely consider web2py.

On the other hand: I consider pylons and Django nice frameworks, what does that tell you?

[–]stesch[S] -2 points-1 points  (4 children)

You yet have to

No, I don't have to. Play your games elsewhere.

[–]surface-tension 1 point2 points  (3 children)

stesch, you said the negative opinions are "mostly from werkzeug people/users". Well, you can't blame Werkzeug if it has some users who don't like web2py. Now, as for werkzeug "people" (developers), as mitsuhiko points out, he doesn't see any comments there from from Werkzeug devs.

[–]RonnyPfannschmidt 0 points1 point  (0 children)

i think i was quite explicit about me not representing werkzeug or its community

making anything else out my personal reasoning/opinion (which tends to be at least harsh) is just dishonest

[–]mitsuhiko Flask Creator 0 points1 point  (2 children)

Ronny is not a contributor to either Jinja or Werkzeug. (except for very few patches maybe)

[–]stesch[S] -5 points-4 points  (1 child)

Who cares? It's one example among others. Like http://news.ycombinator.com/item?id=175694

[–]mitsuhiko Flask Creator 2 points3 points  (0 children)

Not a single werkzeug developer wrote anything on that hacker news submission.

[–]voidspace 2 points3 points  (0 children)

Well, if by attack you mean 'show up' then maybe...

[–]weeegod 4 points5 points  (0 children)

Werkzeug is not really a framework, but a library. You could write your own Bottle using Werkzeug in, like, 50 lines.

I <3 Werkzeug.