Skip to main content

simple standalone WSGI server with code reloading

Project description

James WSGI Server
=================

[James][1] provides a very simple multi-threaded [WSGI][2] 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.


Basic Example
-------------
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.


Serving Static Files
--------------------
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()


Defining Hostname and Port
--------------------------
Per default James listens on [localhost][3] 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()

Autoreloading Code
------------------
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()

Testing James
-------------
You can get this page if you call `james.test()`.


[1]: http://wsgiarea.pocoo.org/james/
[2]: http://www.python.org/peps/pep-0333.html
[3]: http://localhost:8080/

Project details


Release history Release notifications

This version
History Node

0.7.1

History Node

0.7

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page