MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
September
Sun Mon Tue Wed Thu Fri Sat
         
8
2017
Months
Sep


Fri, Sep 08, 2017 10:21 pm

Display a webpage from a Python script

If you just want to display text on a webpage from a Python script, a simple way to print to a web page is shown in the script below:

#!/usr/bin/python

print "Content-type: text/plain\n"
print "Hello world"

If you want to display HTML code, you can use Python code like the following:

#!/usr/bin/python

print "Content-type: text/html"
print
print """<!DOCTYPE HTML>
<html lang="en">
<body>
<h1>Hello World!</h1>
</body>
</html>
"""

[ More Info ]

[/languages/python] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo