You have to enclose the path to the Python script in double quotes. Double quotes have to be escaped in XML using "
.
You do NOT have to enclose the path to the Python executable in double quotes! In fact, this will not work! If your Python installation is in a non-standard path containing spaces, then you don't need to do anything, as spaces will just work for the executable path (it isn't really IIS/FastCGI module that has issues with spaces, but the invocation of Python where the script path is to be passed as a single argument).
As an example, here is what the configuration looks like if Python is installed in a non-standard path containing spaces (just replace it with C:\python27\
if that doesn't apply to you).
In applicationHost.config
:
<fastCgi>
<application
fullPath="C:\Program Files (x86)\MyApp\Python\python.exe"
arguments=""C:\Program Files (x86)\MyApp\Python\Lib\site-packages\wfastcgi.py""
[...] />
</fastCgi>
In web.config
:
<add name="MyHandler"
path="myapp.py"
verb="*"
modules="FastCgiModule"
scriptProcessor="C:\Program Files (x86)\MyApp\Python\python.exe|"C:\Program Files (x86)\MyApp\Python\Lib\site-packages\wfastcgi.py""
resourceType="Unspecified"
requireAccess="Script" />
EDIT: To set up applicationHost.config
programmatically using appcmd.exe
, you must escape the double quotes in the argument as \"
. For example:
set config /section:system.webServer/fastCgi /+"[
fullPath='C:\Program Files (x86)\MyApp\Python\python.exe',
arguments='\"C:\Program Files (x86)\MyApp\Python\Lib\site-packages\wfastcgi.py\"',
[...]