Newbie CGI problem

  • Thread starter Rory Campbell-Lange
  • Start date
R

Rory Campbell-Lange

#!/usr/bin/python
import cgi
print "Content-type: text/html\n\n"
print "hi"

Gives me the following in my browser:

'''
hi
Content-type: text/html


hi
'''

Why are there two 'hi's?

Thanks,
Rory
 
A

aurora

Not sure about the repeated hi. But you are supposed to use \r\n\r\n, not
just \n\n according to the HTTP specification.
 
M

m

Rory said:
#!/usr/bin/python
import cgi
print "Content-type: text/html\n\n"
print "hi"

Gives me the following in my browser:

'''
hi
Content-type: text/html


hi
'''

Why are there two 'hi's?

Thanks,
Rory

gives just one hi for me.
 
P

Peter Otten

Rory said:
#!/usr/bin/python
import cgi
print "Content-type: text/html\n\n"
print "hi"

Gives me the following in my browser:

'''
hi
Content-type: text/html


hi
'''

Why are there two 'hi's?

You have chosen a bad name for your script: cgi.py.
It is now self-importing. Rename it to something that doesn't clash with the
standard library, and all should be OK.

Peter
 
A

aurora

You have chosen a bad name for your script: cgi.py.
It is now self-importing. Rename it to something that doesn't clash with
the
standard library, and all should be OK.

Peter

You are genius.
 
R

Rory Campbell-Lange

You have chosen a bad name for your script: cgi.py.
It is now self-importing. Rename it to something that doesn't clash with the
standard library, and all should be OK.

Thanks very much. Ouch!
Rory
 

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
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top