WSGI

From Servage Wiki
Jump to: navigation, search

What is WSGI?

WSGI is a python standard for Web-applications and means Web Server Gateway Interface.

Its used as interface between the webserver and the Application you want to run.

For every project a dedicated WSGI handler is required to process the requests for the application.

Such a handler is usually a small script thus just instantiates an object of a class that is delivered together with your project, initializes it and hands over further control to it.


How do I enable WSGI for my Python application?

To let an application run as WSGI application we need to create a .wsgi file that the webserver calls whenever a request for the application is detected.

You can get pre-finished .wsgi scripts for nearly every existing larger Python project in the net so there is usually no need to write your own .wsgi file from scratch. But in most cases you need to modify this .wsgi script a little bit to include additional paths for custom python modules in your accounts homedir.

If have have placed the -wsgi file somewhere in your account its time to configure the server so it knows what to do. This can be done in our control panel.

Go to the WSGI Tab in the settings window of the virtual host you want to enable WSGI for and create a new alias.

The Aliases works like virtual paths in your virtual host. The most common setup is to let your application handle all URL requests. This setup can be done by just entering a / (slash) as alias. But other setups are also possible. For example you can use multiple WSGI applications on your virtual host by entering different aliases like /live, /testing and /old_version or something similar.

Please remember: If you are using / as every single request is directly directed to the WSGI handler and static files can not be served from the DocumentRoot. To serve static files when using / as WSGI-Alias use Path Aliases to create additional Aliases that will overwrite the / alias as its more specific.

Select the .wsgi file your created and save the settings.

Please note: It will take up to 2 hours until the changes take affect on the server.

WSGI integration Howto's

Personal tools
Navigation