Added a way to output stuff if stdout is not utf-8

This commit is contained in:
Morten Delenk 2016-07-31 11:57:35 +02:00
parent 36a73733c6
commit cce6bb0b56
No known key found for this signature in database
GPG key ID: 3F818D0F65DCB490
3 changed files with 9 additions and 3 deletions

View file

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

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from htmlgen import *
import traceback
import sys
import storage
import cgi
import random
@ -46,4 +47,5 @@ for i in range(count):
html.addArticle(aid=aid,**(storage.get("comments-%i"%aid,i)))
print("<!DOCTYPE html>")
print(html.renderSite(True))
sys.stdout.buffer.write(html.renderSite(True).encode('utf8'))
#print(html.renderSite(True))

View file

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