Utilities

This module holds handy utilities for development and debugging of pyroutes applications. The methods found here are _not_ meant for use in production environments, no guarantees are given for their stability or security.

pyroutes.utils.devserver(application, port=8001, address='0.0.0.0', auto_reload=True)

Simple development server for rapid development. Use to create a simple web server. For testing purposes only. Has no builting handling of file serving, use fileserver in this class. Typical usage:

from pyroutes import route, application, utils
#<define routes>
if __name__ == '__main__':
    utils.devserver(application)

This starts a server listening on all interfaces, port 8001. It automatically reloads modified files.

pyroutes.utils.fileserver(request, *path_list)

Simple file server for development servers. Not for use in production environments. Typical usage:

from pyroutes import route, utils
route('/media')(utils.fileserver)

That will add the fileserver to the route /media. If DEV_MEDIA_BASE is defined in settings, host files from this folder. Otherwise, use current working directory.

Note

DEV_MEDIA_BASE and route path is concatenated, i.e. if you use ‘/srv/media’ for as the media base, and map the route to ‘/files’, all files will be looked for in ‘/srv/media/files’

Project Versions

Go to this page on GitHub. (Edit)

Previous topic

Templates

Next topic

Settings

This Page