Contact: fumanchu@aminus.org

Log in as guest/misc to create tickets

How to set up IIS/ASP for use as a WSGI server

Grab source:asp_gateway.py from this site and save it in site-packages, or somewhere else on your Python path. Then create the following Global.asa for your site:

Example Global.asa for a CherryPy? app called "mcontrol":

<script language=Python runat=Server> 
def Application_OnStart():
    Application.Contents("multiprocess") = False
    Application.Contents("multithread") = True
    from mcontrol import chpy
</script>

mcontrol.chpy refers to a hypothetical mcontrol/chpy.py module that sets cherrypy.root, calls cherrypy.server.start(initOnly=True), and does any other application startup. Here's a sample script:

import cherrypy

class HelloWorld:
    def index(self):
        return "Hello world!"
    index.exposed = True

cherrypy.root = HelloWorld()
cherrypy.config.update({"server.environment": "production"})
cherrypy.server.start(initOnly=True, serverClass=None)

Next, you need to create a separate handler.asp file, one for each URL in your site. If that sounds like too much work, it is. You should *really* consider using a rewriter, like ISAPI_Rewrite Lite. Here's an example handler.asp:

<%@Language=Python%>
<%
from wsgiref.asp_gateway import handler
from cherrypy.wsgiapp import wsgiApp

handler(Application, Request, Response).run(wsgiApp)
%>