How do you do a "hello world" in python

randyvalpobb

BANNED
Jun 8, 2005
8
0
151
I am looking for some information on how to do a "hello world" in python and have it run in a separate browser.
 

Marty

Well-Known Member
Oct 10, 2001
630
1
318
Code:
#!/usr/bin/python

# Tell the browser how to render the text
print "Content-Type: text/plain\n\n"

print "Hello, Python!"  # print a test string
Save that in a text file named hello.py

Then link to it with target=_blank attribute to force a new window.

You can get more info here:

http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/
 

randyvalpobb

BANNED
Jun 8, 2005
8
0
151
python code wont parse

It is not parsing the python code for, hello world, when I add iit on a customer's website. It shows up as plain text. Do you know how I get the code to parse. He has 5 pages of code he is trying to get to parse with no success.

Thanks
Randy :eek:
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,441
31
473
Go on, have a guess
Presumably, you're going to need to modify httpd.conf to recognise python scripts for CGI processing. Have you added a handler for .py files etc.? If not, then you'll need to do a net search on configuring python in apache.
 

randyvalpobb

BANNED
Jun 8, 2005
8
0
151
If possible, could you please tell me how to configure python in apache. Could you let me what I need to add in the apache.conf file.

Thanks
Randy :)
 

randyvalpobb

BANNED
Jun 8, 2005
8
0
151
Gracias Chirpy it works. We add an error with the python script 'Premature end of script". We find that invisible charaters will get put there. We deleted them and it works fine.

Thanks a lot
Randy