paulo@91: import os paulo@91: paulo@91: import html paulo@91: paulo@91: paulo@91: TITLE = "myw" paulo@91: REDIRECT_FILE = ".htaccess" paulo@91: paulo@91: paulo@91: def main(environ): paulo@91: links = [] paulo@91: paulo@91: with open(REDIRECT_FILE) as f: paulo@91: for l in f: paulo@91: l = l.lstrip() paulo@91: if l.startswith("Redirect"): paulo@91: ls = l.split() paulo@91: if len(ls) == 4: paulo@91: path = ls[2].strip('"') paulo@91: links.append(os.path.basename(path)) paulo@91: paulo@91: root = html.HTML("html") paulo@91: paulo@91: header = root.header paulo@91: header.title(TITLE) paulo@91: header.link(rel="stylesheet", type="text/css", href="index.css") paulo@91: paulo@91: body = root.body(klass="body") paulo@91: paulo@91: for i in links: paulo@91: div = body.div() paulo@91: div.a(i.capitalize(), href=i) paulo@91: paulo@91: return unicode(root).encode("utf-8") paulo@91: paulo@91: paulo@91: def app(environ, start_response): paulo@91: response_body = main(environ) paulo@91: response_headers = [ paulo@91: ("Content-Type", "text/html; charset=UTF-8"), paulo@91: ("Content-Length", str(len(response_body))), paulo@91: ] paulo@91: start_response("200 OK", response_headers) paulo@91: paulo@91: return [response_body]