mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-26 13:01:06 -05:00
Further improve web page code.
This commit is contained in:
parent
1844e63234
commit
6d44e3185a
11
server.py
11
server.py
@ -74,16 +74,17 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
def page(self, query):
|
def page(self, query):
|
||||||
def write(subtitle, body):
|
def write(subtitle, body):
|
||||||
page = [
|
page = [
|
||||||
'<html>', '<head>\n<title>BanTracker%s</title>' % (' » %s' % subtitle if subtitle else ''),
|
'<!DOCTYPE html>', '<html>', '<head>',
|
||||||
|
'<title>BanTracker%s</title>' % (' » %s' % subtitle if subtitle else ''),
|
||||||
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
|
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
|
||||||
'<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />',
|
'<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />',
|
||||||
'</head>\n<body style="margin:0.5em;width:98%;" class="container">'
|
'</head>', '<body style="margin:0.5em; width:98%;" class="container">'
|
||||||
] + body + ['</body>\n</html>']
|
] + body + ['</body>', '</html>']
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-type","text/html")
|
self.send_header("Content-Type", "text/html")
|
||||||
full = '\n'.join(page)
|
full = '\n'.join(page)
|
||||||
print('HTML lines %s' % len(full))
|
print('HTML lines %s' % len(full))
|
||||||
self.send_header("Content-length",len(full))
|
self.send_header("Content-Length", len(full))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(full.encode('utf-8'))
|
self.wfile.write(full.encode('utf-8'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user