a little more help with python server-side scripting

Gerard Flanagan grflanagan at yahoo.co.uk
Thu Feb 23 18:29:38 EST 2006


John Salerno wrote:
>
> Ok, seems like the verdict is that the server doesn't have mod_python
> nor does it detect the .psp extension. It can, however, detect the .py
> extension. But does this mean I can simply include Python code in my
> HTML files, and then give my HTML files a .py extension?

No.

[...]

>
> ? They say:
>
> "Please note that you may map .py to .html extension. However, if you
> set this mapping, .html will not work with the normal html tags anymore."
>
> But I don't know what this means about 'mapping' the extension and what
> it means that html tags won't work anymore.

John

There is a configuration section in the IIS management tool
(inetmgr.exe) called 'Application Mappings' which maps file extensions
to applications.  For example, on my (WinXP) machine I have:

  .aspx -->
C:\WINDOWS\Microsoft.NET\Framework\v1.14322\aspnet_isapi.dll
  .asp   -->  C:\WINDOWS\system32\inetsrv\asp.dll
  .php   -->  C:\Program Files\PHP\Php51\php-cgi.exe

among others.  So if IIS receives a request for a url with one of these
extensions it passes that request on to the relevant program.  You
could map '.py' to 'python.exe %s %s' but any '.py' files would have to
be pure Python.

IIS doesn't need any help with standard, static .html requests, it can
serve those itself.  It may be possible to map '.html' to any of the
three applications above and still have static HTML pages function
identically (even if this would create a pointless overhead ), however
you couldn't map '.html' to 'python.exe' and expect anything meaningful
- there is nothing like 'python-cgi.exe' that understands HTML with or
without inlined python code.

Gerard




More information about the Python-list mailing list