[Tutor] Reading an html file into a cgi script.

Douglas N. Shawhan lysdexia at crackrabbit.com
Tue Sep 14 08:14:03 CEST 2004


I would like to pull lines from an html file and include them in a cgi 
script. (python2.1, openbsd 3.5, apache)

I have a file called 'header.html', which contains the lines:

'''Content-type: text/html\n\n'''
'''<table><tr>'''

I then attempt to load it from the script:

HEADER = open('header.html', 'r')
HEADER = HEADER.readlines()
for line in HEADER:
    print line

The "Content-type" line may or may not be parsed correctly - it doesn't 
show up in the output, but the html contained in the file is definitely 
not parsed:

'''<table><tr>'''



Tue Sep 14 00:58:30 2004 | None | 1313 Mockingbird ln.| None | 1095141610.24 | 1095142510.24
<td>Tue Sep 14 00:58:30 2004 | None | 1313 Mockingbird ln.| None | 1095141610.24 | 1095142510.24</td>
<td>Tue Sep 14 00:58:30 2004 | None | 1313 Mockingbird ln.| None | 1095141610.24 | 1095142510.24</td>
<td>Tue Sep 14 00:58:30 2004 | None | 1313 Mockingbird ln.| None | 1095141610.24 | 1095142510.24</td>
<td>Tue Sep 14 00:58:30 2004 | None | 1313 Mockingbird ln.| None | 1095141610.24 | 1095142510.24</td>

'''</table>'''



Note that the first line has no <td> tags. *scratch* *scratch*

What am I missing here?



More information about the Tutor mailing list