Using web.py as non blocking http-server Using web.py as non blocking http-server multithreading multithreading

Using web.py as non blocking http-server


I found a working solution. In a seperate module i create my webserver:

import webimport threadingclass MyWebserver(threading.Thread):    def run (self):        urls = ('/', 'MyWebserver')        app = web.application(urls, globals())        app.run()    def POST ...

In the main programm i just call

MyWebserver().start()

and than go on with whatever i want while having the webserver working in the background.


Wouldn't is be simpler to re-write your main-loop code to be a function that you call over and over again, and then call that from the function that you pass to runsimple...

It's guaranteed not to fully satisfy your requirements, but if you're in a rush, it might be easiest.


or just use Tornado, a non-blocking webserver for Python that has an API similar to webpy - http://www.tornadoweb.org/