How does a common Colubrid application look like? Here are some examples.
Run an example have a look into the documentation. Or if you're lazy: just save them and execute it with Python. Then Colubrid will start the builtin webserver.
This example outputs "Hello World":
from colubrid import BaseApplication, execute
class HelloWorld(BaseApplication):
def process_request(self):
self.request.write('Hello World')
app = HelloWorld
if __name__ == '__main__':
execute()
When you call request.write, Colubrid caches the data in a buffer. When the applications raises a ColubridException or returns from the process_request method, this content is sent to the browser. You can change this behavior using send_response:
from colubrid import BaseApplication
from time import sleep
class DynamicResponse(BaseApplication):
def process_request(self):
def countdown():
yield '<h1>Dynamic Response</h1>'
for i in xrange(500, 0, -1):
yield ' %s ' % i
sleep(0.01)
self.request.send_response(countdown())
app = DynamicResponse
if __name__ == '__main__':
execute()