I’ve been teaching myself python and cgi scripting, and I know that your basic script looks like
#!/usr/local/bin/python
import cgi
print "Content-type: text/html"
print
print "<HTML>"
print "<BODY>"
print "HELLO WORLD!"
print "</BODY>"
print "</HTML>"
My question is, if I have a big HTML file I want to display in python (it had lines and lines of code and sone JS in it) do I have to manually add ‘print’ in front of each line and turn “s into \” , etc? Or is there a method or script that could convert it for me?
Thanks!
Python supports multiline strings, so you can print out your text in one big blurb.
They support all string operations, including methods (
.upper(),.translate(), etc.) and formatting (%), as well as raw mode (rprefix) and theuunicode prefix.