Server

You can serve rivr with either the build in development server, or you can use any WSGI compatible server such as gunicorn.

Development Server

By default, the development server can be used with any rivr callable view, this includes middleware and views.

rivr.serve(handler: Callable[[rivr.http.request.Request], rivr.http.response.Response], host: str = 'localhost', port: int = 8080, debug: bool = True)

Starts a developent server on the local machine. By default, the server runs on port 8080 on localhost. You can pass in a different hostname and/or IP using the keyword arguments.

The development server automatically returns pretty HTML error pages, this can be turned off by setting the debug keyword to False.

import rivr

def example_view(request):
    return rivr.Response('<html><body>Hello world!</body></html>')

if __name__ == '__main__':
    rivr.serve(example_view)

WSGI Server

It’s really simple to use a WSGI server, you can use rivr’s WSGIHandler to wrap your rivr callable view.

import rivr
from rivr.wsgi import WSGIHandler

def example_view(request):
    return rivr.Response('<html><body>Hello world!</body></html>')

wsgi = WSGIHandler(example_view)

Then you can simply point your WSGI server to the wsgi method. For example, to do this with gunicorn you can run the following:

$ gunicorn example_wsgi:wsgi