Template.cgi: Difference between revisions
(New page: <source lang="python"> #!/usr/bin/python print "Content-type: text/html" print print """<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//...) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Examples of simple python scripts to use as a basis of a dynamic HTML page. | |||
== Minimal == | |||
<source lang="python"> | <source lang="python"> | ||
#!/usr/bin/python | #!/usr/bin/python | ||
print "Content-type: text/html" | print "Content-type: text/html; charset=utf-8" | ||
print | print | ||
print """< | print "<html><head><title>My Hello World Page</title></head><body>" | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |||
# do interesting stuff in Python | |||
for i in range(100): | |||
print i, " " | |||
print "</body></html>" | |||
</source> | |||
== More Complete == | |||
<source lang="python"> | |||
#!/usr/bin/python | |||
print "Content-type: text/html; charset=utf-8" | |||
print | |||
print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | <head> | ||
<title> | <title>My Hello World Page</title> | ||
</head> | </head> | ||
<body> | <body> | ||
<h1> | <h1>Hello World</h1> | ||
""" | """ | ||
# do interesting stuff in Python | |||
for i in range(100): | |||
print i, " " | |||
print """ | print """ | ||
</body> | </body> | ||
</html> | </html> |
Latest revision as of 14:48, 9 February 2009
Examples of simple python scripts to use as a basis of a dynamic HTML page.
Minimal
#!/usr/bin/python
print "Content-type: text/html; charset=utf-8"
print
print "<html><head><title>My Hello World Page</title></head><body>"
# do interesting stuff in Python
for i in range(100):
print i, " "
print "</body></html>"
More Complete
#!/usr/bin/python
print "Content-type: text/html; charset=utf-8"
print
print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>My Hello World Page</title>
</head>
<body>
<h1>Hello World</h1>
"""
# do interesting stuff in Python
for i in range(100):
print i, " "
print """
</body>
</html>
"""