Slightly off-topic... (sending HTML data through a Python socket)

Gordon McMillan gmcm at hypernet.com
Sun Jul 29 14:01:36 EDT 2001


Adonis Vargas wrote:

> I am attempting to send HTML data back to a browser which connected to X
> port. I have goen over the the HTML RFC and just can not get it to work.
> What I am attempting to do is send a redirect back to the browser. So
> far I have something as follows:
> 
> c.send("""
>           <HTML>
>           <HEAD>
>           <META HTTP-EQUIV=\"Refresh\"
> Content=0;Host=\"http://www.python.org/\">"
>           </HEAD>
>           </HTML>
>           """)

Eric already pointed out the correct format of the http-equiv line.

You're not telling us how this is being sent. Is the browser first
getting a line like "HTTP/1.0  200  OK\r\n"? In other words, you
need to follow the HTTP protocol before HTML does you any good. If
you're using one of the standard HTTP Servers, this is getting 
taken care of for you. But if 'c' is a socket, you'll need to
do the HTTP stuff yourself.

(No need to escape a quote in a triple-quoted string.)

- Gordon



More information about the Python-list mailing list