James provides a very simple multi-threaded WSGI server implementation based on the HTTPServer from Python's standard library.
You can host multiple applications on one host as well as static files.
Important - James is is a simple server for use in testing or debugging WSGI applications. It hasn't been reviewed for security issues. Don't use it for production use.
Use it for demo and debugging purposes.
You can add a James call using the __name__ hook on the bottom of
your application file:
if __name__ == '__main__':
from james import WSGIServer
WSGIServer(applications={'/': my_application}).run()
This example assumes that your application is named my_application.
Your application will be mounted on /. Using the applications
parameter you can install more than one application on the same james
server.
James can also handle static files. For this purpose it takes a
parameter files:
if __name__ == '__main__':
from os import path
from james import WSGIServer
base = path.dirname(__file__) + '/static'
WSGIServer(
applications={
'/': my_application
},
files={
'/favicon.ico': base + '/favicon.ico',
'/css': base + '/css',
'/img': base + '/img'
}
).run()
Per default James listens on localhost Port 8080.
To change this behavior you can use the parameters hostname and
port:
if __name__ == '__main__':
from james import WSGIServer
WSGIServer(hostname='mycomputername', port=80,
applications={'/': myapplication}).run()
Per default James is persistent which means imported module get only
reloaded when you restart the server. Because James is meant as an
developement server you can enable automatically code reloading with
the autoreload parameter:
if __name__ == '__main__':
from james import WSGIServer
WSGIServer(applications={'/': myapplication},
autoreload=True).run()
You can get this page if you call james.test().