a little more help with python server-side scripting

D

Dennis Lee Bieber

new method to do what I'm trying to do. I guess I'm not well-versed
enough in Python to even attempt this kind of thing yet. I didn't
realize it would be this complicated. I guess I hoped it would be as

Most of your questions aren't Python related, per se... They are all
webserver administrative details.

"Does the server support language <x>"
"Is language <x> available as an embedded script language"

etc.
easy as including some PHP code and letting the server detect the .php
extension and handle it all. I'm going to try to solidify the basics
first, then move on to web programming a little later.

Start at the simpler end: straight CGI, wherein a program in
language <x> is run (as if from a console); any form data submitted
should have been parsed into the environment and available to the
program; the program /generates/ an entire response page including HTTP
headers, and writes that on stdout.

From there, move up to a templating system, where the shell of the
response page is a separate file with special tags for those places
where dynamic data is supposed to be substituted, and the <x> program
builds up the dynamic data and passes it to the template rendering
function.

Then worry about trying to do server side embedded scripting; you
may find you didn't need it.


FYI: "ASP" stood for "Active Server Pages"; basically M$ technology for
dynamically accessing the content of a page before rendering and return.
"PSP" and "JSP" are names in a similar scheme, but language specific,
and likely platform independent (IE, NOT M$ IIS).
--
 
P

Paul Boddie

John said:
Well, I appreciate the help. I'm trying to figure it out, but it seems
like with each new post, there is some new technology being mentioned or
new method to do what I'm trying to do.

Let's just consolidate what we've learned here. Your provider says that
you can serve up two different things; the first one being...

bits of Python code that are embedded within an HTML file

.... (this being from a message you quoted), although they don't really
make themselves totally clear, because they then say...

that after mapping .html will no
longer be call as normal html file to be loaded on the browser as the
IIS server now will parse .html with the Python executable engine.
Your user will need to embed the Python coding into each of the .html
file in order for it to be load properly on the browser.

....which sounds like ASP to me, noting that the "Python executable
engine" is probably the Active Scripting engine which can work with
Python. So let's call that the "ASP with Python" route.

Now, the other thing they said you could serve up are Python scripts:

Save your python script as .py file on the wwwroot and
you may call the scripts using http://www.yourdomain.com/yourfile.py

What these scripts have to do when they run is to output some text
which consists of some headers and the text of a Web page that will
appear in your browser (and you can test them yourself before you
upload them by seeing if they output the expected stuff when you run
them). Let's call this the "CGI with Python" route.
I guess I'm not well-versed
enough in Python to even attempt this kind of thing yet. I didn't
realize it would be this complicated. I guess I hoped it would be as
easy as including some PHP code and letting the server detect the .php
extension and handle it all. I'm going to try to solidify the basics
first, then move on to web programming a little later.

Well, guessing at your configuration from what the support people have
said, it may be simpler to just test things with the "CGI with Python"
option first. So, if you take a CGI program such as one from this
page...

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52220

....like this one...

#!/usr/bin/python
import cgi
cgi.test()

....save it as yourfile.py, upload it as instructed above, and then
visit your site (also as instructed above), you should see some test
output from Python. (Again, you can check the output by running
yourfile.py locally and seeing that it prints out some HTML to the
screen.)

If you want to do the PHP-style thing - the "ASP with Python" option -
then you probably need to make a Web page, similar to that described
here...

http://support.microsoft.com/default.aspx?scid=kb;en-us;276494

....save it as yourfile.html (given what they said in their response to
you, although most people thought it should be yourfile.asp - why not
try both?!), upload it, and then visit your site (as instructed above,
but remembering that you're looking for a file called yourfile.html or
yourfile.asp instead of yourfile.py).

If the yourfile.html thing doesn't work but the yourfile.asp does, then
forget about what they said about HTML files and .html and remapping
things: just call your "ASP with Python" files names with .asp on the
end.

To sum up:

1. Copy the three line "CGI with Python" example, save it as
yourfile.py, upload it, test it. If it works, celebrate and move
on to step 2. If it doesn't, move on to step 2 anyway. ;-)

2. Copy the Web page example from the Microsoft link, save it
as yourfile.asp and also as yourfile.html, upload them, test
them. If one of them works, celebrate and note down whether
you should be using .asp or .html on the end of your filenames.
If both of them work, celebrate more vigorously! If neither work,
try and tell us what went wrong.

Good luck!

Paul
 
J

John Salerno

Paul said:
To sum up:

1. Copy the three line "CGI with Python" example, save it as
yourfile.py, upload it, test it. If it works, celebrate and move
on to step 2. If it doesn't, move on to step 2 anyway. ;-)

2. Copy the Web page example from the Microsoft link, save it
as yourfile.asp and also as yourfile.html, upload them, test
them. If one of them works, celebrate and note down whether
you should be using .asp or .html on the end of your filenames.
If both of them work, celebrate more vigorously! If neither work,
try and tell us what went wrong.

Thank you. I'm going to study your response and give it all a try! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,285
Messages
2,571,416
Members
48,107
Latest member
AmeliaAmad

Latest Threads

Top