Configuring Python with IIS 7.0

by timvasil 3/5/2012 11:06:00 PM

Recently I thought I'd give Python a try for web development.  Configuring it with 64-bit Windows and IIS 7.0 took a bit of trial and error, though, and I didn't find these steps comprehensively laid out anywhere on the web.  So here goes:

  1. Download the 32-bit version of Python 2.6 here.  To work with the Python ISAPI filter, it's important you choose the 32-bit variant of the 2.6 version.  I accepted all defaults during the installation.
  2. Download Python ISAPI Extension for IIS 2.6 (pyisapie) here.  I unzipped it into a subfolder of C:\Python2.6
  3. Create an environment variable called PYTHONHOME and set it to where you installed Python, e.g. C:\Python2.6.
  4. Restart Windows.  Since IIS inherits its environment block from services.exe, which cannot be restarted, you need to reboot so the ISAPI filter sees the PYTHONHOME variable.
  5. Configure IIS to use the ISAPI extension:
    1. Create a 32-bit application pool (Advanced Settings > Enable 32-Bit Applications = True)
    2. Create a web site (or application) and configure it to use the application pool you just created
    3. Add a "Script Map" handler mapping with a request path of "*.py", an executable location of the Python ISAPI DLL (e.g. C:\Python26\PyISAPIe-1.1.0-rc4-Py2.6\PyISAPIe.dll), and any name you'd like.  (Accepting Request Restriction defaults is fine.)
  6. In the home directory of your website, create a Python script to test your handiwork, e.g. a file named page.py with this code:
     
    from Http import *
    def Request():
        Header("Content-type: text/html")
        Write("Hello, World!")
      
  7. Visit the URL (e.g. http://website/page.py); if all is well, the message "Hello, world!" appears!

Tags:

IIS | ISAPI | Python

Run a 32-bit ISAPI DLL on 64-bit IIS 7

by timvasil 11/23/2007 9:25:00 PM

I knew this would be challenging, but the worst part of getting a 32-bit ISAPI DLL running in the 64-bit version of IIS 7 is the really crummy UI.  Here are the steps:

Allow the ISAPI DLL

  1. With the root node selected (the computer name), double-click Isapi & CGI Restrictions
  2. Click Add... on the sidebar
  3. Type/browse for the path to your ISAPI DLL.
  4. Check Allow extension path to execute.

Create a 32-bit Application Pool

  1. With the Application Pools node selected, click Add Application Pool... on the sidebar.
  2. Type in a name and choose the Classic pipeline. 
  3. Opt not to start the pool immediately.
  4. Click OK.
  5. Select the new pool.
  6. Click Advanced Settings... on the sidebar.
  7. Change Enable 32-Bit Applications (General category) to True.
  8. Start the pool.

Create the Application

  1. Right click on the Web Sites > Default Web Site node and click Add Application...
  2. Choose the alias, application pool, and physical path.  The application pool you choose should be the 32-bit one you just created.

Allow ISAPI DLLs to Execute within the Application

  1. Select the application node in the tree view and double click Hander Mappings.
  2. Click Add Script Map...
  3. Type a request path of *.dll, select the IsapiModule module, and give it a name.
  4. Click OK.

Note:  You can also enable the existing ISAPI entry at the Default Web Site level, or enable feature delegate for ISAPI Filters at the root node (computer) level and then edit it at the application level.

Tags:

IIS | ISAPI

Search

Calendar

«  June 2013  »
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

View posts in large calendar

Recent comments

Archive