Home > Bottle, gevent, Python > Bottle and gevent

Bottle and gevent

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.host, self.port), handler).serve_forever()

run(app=myapp, server=GEventServer, host='localhost', port=8080)
Categories: Bottle, gevent, Python
  1. wierz
    January 30, 2012 at 3:01 am

    hey, good job
    but when i try with reloader options then not works…

    thanks ..

  2. January 30, 2012 at 8:07 pm

    You’re right, by using Gevent adapter it is not able to use the reloader (not suitable for debugging purpose) 🙂

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: