Internal Server

Since version 0.9.8, colubrid doesn't ship an internal server any more. It uses the HTTP WSGI server of paste.

There is a function execute for simple application serving with a reloader and static exports.

Basic usage

Just import the execute function to serve an application:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication)

If you don't define the first parameter which is the reference to your application class, colubrid will look for an object called app.

Defining static exports

The second parameter can be a dict which defines static exports. In fact it just wrapps the application in the StaticExports middleware located in colubrid.server:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication, {'/favicon.ico', 'myicon.ico'})

Enable evalexception feature

The debugger features a system which lets you execute arbitrary code in exceptions' stack frames, like paste's evalexception. Because this is a potential security risk, you must activate it explicitly with an additional keyword argument:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication, debug=True, evalex=True)

Disable debugger

If you don't want the debugger because you want to use your own, you can do that too:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication, debug=False)

Enable automatic reloader

If you're sick of restarting your server after each code change you should enable the reloader. It watches code changes and reloads the server on the fly:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication, reload=True)

Defining hostname and port

If you don't want your server running on localhost:8080, you can customize that using two parameters:

if __name__ == '__main__':
    from colubrid import execute
    execute(MyApplication, hostname='myhostname', port=3333)
Last Change: 10 Sep 2006 17:55:20 | show source