maybe I shouldo nly use buffered writes?

This commit is contained in:
Morten Delenk 2016-07-31 12:04:02 +02:00
parent 01a93657ea
commit 7c27203744
No known key found for this signature in database
GPG key ID: 3F818D0F65DCB490
3 changed files with 6 additions and 6 deletions

View file

@ -2,7 +2,6 @@
from htmlgen import * from htmlgen import *
import sys import sys
import storage import storage
print("Content-type: text/html\r\n\r\n")
html=htmlgen.HTMLgen(pagelayout.getLayoutXML().decode('utf-8'),"Home Page") html=htmlgen.HTMLgen(pagelayout.getLayoutXML().decode('utf-8'),"Home Page")
count=storage.count("articles") count=storage.count("articles")
for i in range(count): for i in range(count):
@ -13,7 +12,8 @@ for i in range(count):
except: except:
html.addArticle(**storage.get("articles",i), aid=i) html.addArticle(**storage.get("articles",i), aid=i)
print("<!DOCTYPE html>") sys.stdout.buffer.write("Content-type: text/html\r\n\r\n".encode('utf8'))
sys.stdout.buffer.write("<!DOCTYPE html>".encode('utf8'))
sys.stdout.buffer.write(html.renderSite().encode('utf8')) sys.stdout.buffer.write(html.renderSite().encode('utf8'))
sys.stdout.flush() sys.stdout.flush()
#print(html.renderSite()) #print(html.renderSite())

View file

@ -9,7 +9,6 @@ import base64
from io import BytesIO from io import BytesIO
from captcha.image import ImageCaptcha from captcha.image import ImageCaptcha
import time, string import time, string
print("Content-type: text/html\r\n\r\n")
form=cgi.FieldStorage() form=cgi.FieldStorage()
aid=int(form["aid"].value) aid=int(form["aid"].value)
try: try:
@ -46,7 +45,8 @@ count=storage.count("comments-%i"%aid)
for i in range(count): for i in range(count):
html.addArticle(aid=aid,**(storage.get("comments-%i"%aid,i))) html.addArticle(aid=aid,**(storage.get("comments-%i"%aid,i)))
print("<!DOCTYPE html>") sys.stdout.buffer.write("Content-type: text/html\r\n\r\n".encode('utf8'))
sys.stdout.buffer.write("<!DOCTYPE html>".encode('utf8'))
sys.stdout.buffer.write(html.renderSite(True).encode('utf8')) sys.stdout.buffer.write(html.renderSite(True).encode('utf8'))
sys.stdout.flush() sys.stdout.flush()
#print(html.renderSite(True)) #print(html.renderSite(True))

View file

@ -2,7 +2,6 @@
from htmlgen import * from htmlgen import *
import sys import sys
import storage import storage
print("Content-type: text/html\r\n\r\n")
html=htmlgen.HTMLgen(pagelayout.getLayoutXML().decode('utf-8'),"Home Page") html=htmlgen.HTMLgen(pagelayout.getLayoutXML().decode('utf-8'),"Home Page")
count=storage.count("articles") count=storage.count("articles")
for i in range(count): for i in range(count):
@ -13,7 +12,8 @@ for i in range(count):
except: except:
html.addArticle(aid=i, **storage.get("articles",i)) html.addArticle(aid=i, **storage.get("articles",i))
print("<!DOCTYPE html>") sys.stdout.buffer.write("Content-type: text/html\r\n\r\n".encode('utf8'))
sys.stdout.buffer.write("<!DOCTYPE html>".encode('utf8'))
sys.stdout.buffer.write(html.renderSite().encode('utf8')) sys.stdout.buffer.write(html.renderSite().encode('utf8'))
sys.stdout.flush() sys.stdout.flush()
#print(html.renderSite()) #print(html.renderSite())