X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_lib%2Fnet%2Fwww%2Futil.py;h=40021b79679740aa588454a7b86c039b0b6c77b2;hb=fb3af94919a9ee18ba1c35f927f19837f057fa1f;hp=1d9d72aa9bfcfbeaef493562d1e7b495d5d1d25e;hpb=9a523766e02fc3c5d1df4550385a604dca8e6e80;p=m_lib.git diff --git a/m_lib/net/www/util.py b/m_lib/net/www/util.py index 1d9d72a..40021b7 100644 --- a/m_lib/net/www/util.py +++ b/m_lib/net/www/util.py @@ -1,21 +1,22 @@ """Common WWW/CGI utilities""" +from __future__ import print_function import sys, os def exception(str = ""): if sys.exc_type == SystemExit: # pass exit() normally return - - print "Content-Type: text/html" - print # Terminate HTTP headers + + # Add the second linefeed to terminate HTTP headers + print("Content-Type: text/html\n") import html - print html.exception() + print(html.exception()) if str: - print str + print(str) sys.exit(1) @@ -24,10 +25,10 @@ def error(err_str): if not err_str: err_str = "Unknown error" - print "Content-Type: text/html" - print # Terminate HTTP headers + # Add the second linefeed to terminate HTTP headers + print("Content-Type: text/html\n") - print str(err_str) + print(str(err_str)) sys.exit(1) @@ -52,7 +53,7 @@ def convert_empty(estr): def gen_html(title, body): - print """ + print(""" @@ -64,7 +65,7 @@ def gen_html(title, body): %s </BODY> </HTML> - """ % (title, body) + """ % (title, body)) def mkexpires(hours=1, minutes=0, seconds=0):