Archive for the ‘Python’ Category

Bottle and gevent

December 14, 2010 2 comments

I’m new using Python, also Bottle. After learning some frameworks I decide give a chance to Bottle as web framework. Default WSGIRefServer (for development) give me some lack while refresh http get from Google Chrome fast.

I think I need replace the default one: gevent. Searching anywhere found nothing about integrating Bootle on gevent. So here is mind, feel free to correct.

from bottle import Bottle, run, ServerAdapter

myapp = Bottle()

def index():
    return "Hello World"

class GEventServer(ServerAdapter):
    """ Fast HTTP Server """
    def run(self, handler):
        from gevent import monkey; monkey.patch_all()
        from gevent.wsgi import WSGIServer
        WSGIServer((, self.port), handler).serve_forever()

run(app=myapp, server=GEventServer, host='localhost', port=8080)
Categories: Bottle, gevent, Python