a little more help with python server-side scripting

Gerard Flanagan grflanagan at yahoo.co.uk
Fri Feb 24 11:08:43 EST 2006


John Salerno wrote:
> Kent Johnson wrote:
> > John Salerno wrote:
> >> Magnus Lycka wrote:
> >>
> >>> The other option is ASP. You have been given information about
> >>> that already. Be aware that ASP does not imply VBScript. You can
> >>> use Python in ASP as long as that's enabled. It seems to be exactly
> >>> what you are asking for, so I don't understand why you seem to reject
> >>> it. Don't you like the file name endings?
> >>
> >>
> >> Maybe I'm misunderstanding what is meant when you say to use ASP. I'm
> >> thinking that it involves having to learn another language (such as C#
> >> with ASP.NET), instead of writing my code in Python. Is that not the
> >> case?
> >
> > See http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B276494
> >
> > The last example on this page is exactly what you have been asking for.
> >
> > Kent
>
> But isn't this code:
>
> Response.Write('Python Test<br>')
> Response.write('<h3>Smaller heading</hr>')
>
> written using ASP instead of Python?


Here's a demo script called 'tut1.asp' located in
'site-packages\win32comext\axscript\Demos\client\asp':

<HTML>

<SCRIPT Language="Python" RUNAT=Server>

for i in range(3,8):
  Response.Write("<FONT SIZE=%d>Hello World!!<BR>" % i)

</SCRIPT>

</HTML>

###################

and here is 'CreateObject.asp' from the same directory:

<HTML>

<SCRIPT Language="Python" RUNAT=Server>

# Just for the sake of the demo, our Python script engine
# will create a Python.Interpreter COM object, and call that.

# This is completely useless, as the Python Script Engine is
# completely normal Python, and ASP does not impose retrictions, so
# there is nothing the COM object can do that we can not do natively.

o = Server.CreateObject("Python.Interpreter")

Response.Write("Python says 1+1=" + str(o.Eval("1+1")))

</SCRIPT>

</HTML>


Gerard




More information about the Python-list mailing list