write html-headers (utf-8)

Kent Johnson kent37 at tds.net
Mon May 30 08:26:55 EDT 2005


db wrote:
> Hello all,
> 
> I hope this is the correct newsgroup for this question.
> 
> Does anybody know how I can write a html-header with python(cgi)? 
> The problem is, I have a few html templates in which I have a header e.g:
> 
> <!DOCTYPE  HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

If you are using CGI you can set the Content-Type header directly. Before you output your HTML do
print "Content-Type: text/html; charset=UTF-8"
print  # blank line, end of headers

Kent



More information about the Python-list mailing list