Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

James is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.7.1 Failed View build log
Windows (64-bit)
0.7.1 Failed View build log
Mac OS X (10.5+)
0.7.1 Failed View build log
Linux (32-bit)
0.7.1 Failed View build log
Linux (64-bit)
0.7.1 Failed View build log
 
Links
License
GNU General Public License (GPL)
Lastest release
version 0.7.1 on Jan 5th, 2011

[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/

Subscribe to package updates

Last updated Jan 5th, 2011

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.