-#!/usr/bin/env python
+#!/usr/bin/env python2
import web
import os
import smtplib
import hashlib
import sys
+from wsgiref.handlers import CGIHandler
pwd = os.path.dirname( os.path.realpath( __file__ ) )
sys.path.append(pwd)
entries = [markdoku.markdown(readFile(x)) for x in filelist]
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(templatesdir)
+ web.header("Content-Type","text/html; charset=utf-8")
return render.multiday(zip(dates, entries, commentcounts), "Entries from %s" % theyear)
class month:
entries = [markdoku.markdown(readFile(x)) for x in filelist]
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(templatesdir)
+ web.header("Content-Type","text/html; charset=utf-8")
return render.multiday(zip(dates, entries, commentcounts), "Entries from %s, %s" % (monthnames[themonth], theyear))
class day:
def GET(self, year, month, day):
filename = os.path.join(entriesdir, "%s-%s-%s.txt" % (year, month, day))
+ web.header("Content-Type","text/html; charset=utf-8")
if os.path.isfile(filename):
entry = markdoku.markdown(readFile(filename))
commentfilelist = os.listdir(commentsdir)
entries = [markdoku.markdown(readFile(x)) for x in filelist]
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(templatesdir)
+ web.header("Content-Type","text/html; charset=utf-8")
return render.multiday(zip(dates, entries, commentcounts))
class pastmonth:
entries = [markdoku.markdown(readFile(x)) for x in filelist]
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(templatesdir)
+ web.header("Content-Type","text/html; charset=utf-8")
return render.multiday(zip(dates, entries, commentcounts))
class pastweek:
entries = [markdoku.markdown(readFile(x)) for x in filelist]
commentcounts = map(len, map( getCommentFiles, dates))
render = web.template.render(templatesdir)
+ web.header("Content-Type","text/html; charset=utf-8")
return render.multiday(zip(dates, entries, commentcounts))
class redir:
#application = web.wsgifunc(web.webpyfunc(urls, globals()))
if __name__ == "__main__":
- ## The web.py 0.3+ way
- app.run()
- ## The web.py 0.2 way
- #web.run(urls, globals())
+ # CGI interface
+ CGIHandler().run(application)
+ ## The web.py 0.3+ way
+ #app.run()
+ ## The web.py 0.2 way
+ #web.run(urls, globals())