Mercurial > mozilla > hg > talosnames
changeset 19:aae0a420c4f7
should now actually do something
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 18:36:50 -0700 |
parents | 76a8d2bd4007 |
children | 0a829ad6e116 |
files | talosnames/web.py |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/talosnames/web.py Tue Jul 10 18:33:15 2012 -0700 +++ b/talosnames/web.py Tue Jul 10 18:36:50 2012 -0700 @@ -4,20 +4,30 @@ web handler for talosnames """ +import os +import tempita from api import TalosNames from webob import Request, Response, exc +here = os.path.dirname(os.path.abspath(__file__)) +template = os.path.join(here, 'templates', 'index.html') + class Handler(object): def __init__(self, **kw): self.api = TalosNames() + self.template = file(template).read() def __call__(self, environ, start_response): request = Request(environ) response = Response(content_type='text/plain', - body="talosnames") + body=self.render()) return response(environ, start_response) + def render(self): + template = tempita.HTMLTemplate(self.template) + return template.substitute({}) + if __name__ == '__main__': from wsgiref import simple_server app = Handler()