[Tutor] python cgi single double quotes

nitin chandra nitinchandra1 at gmail.com
Tue Jul 19 14:43:36 EDT 2016


Hi

I wrote python+cgi script on hostgator server and I could embed html like:-

code folder :- /home/userName/public_html/*.cgi

#!/usr/bin/env python

print "Content-Type:text/html\n\n"

print
print """<html>
...

<script type='text/javascript'
src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=3.0.1'></script>
<script type='text/javascript' src='js/infinite-rotator.js'></script>

...

</html>"""

The above style / way of coding works. Even on my laptop where the
code is in /var/www/<projDir>

Now I have taken a VPS, using command line, I installed apache2.4,
python 2.7, but I am not able to use the same code with triple quotes
(""") to open and close the code block.

I am forced to use

#!/usr/bin/env python

import cgi
import psycopg2

print "Content-type:text/html\r\n\r\n"
print '<html>'
print '....'
print '...'
print '</html>'

Do I need to do some thing to apache config such that I can use Triple
quote to embed.

Also, if I ReUse some of the previous code, it give 500 error.

Any solutions ?

Thanks

Nitin


More information about the Tutor mailing list