comparison myw/redirect_app.py @ 92:96a5e2055acb

myrss: update FEEDS
author paulo
date Mon, 28 Aug 2017 00:13:10 -0600
parents
children 259a484f691b
comparison
equal deleted inserted replaced
-1:000000000000 0:e92febe74166
1 import os
2
3 import html
4
5
6 TITLE = "myw"
7 REDIRECT_FILE = ".htaccess"
8
9
10 def main(environ):
11 links = []
12
13 with open(REDIRECT_FILE) as f:
14 for l in f:
15 l = l.lstrip()
16 if l.startswith("Redirect"):
17 ls = l.split()
18 if len(ls) == 4:
19 path = ls[2].strip('"')
20 links.append(os.path.basename(path))
21
22 root = html.HTML("html")
23
24 header = root.header
25 header.title(TITLE)
26 header.link(rel="stylesheet", type="text/css", href="index.css")
27
28 body = root.body(klass="body")
29
30 for i in links:
31 div = body.div()
32 div.a(i.capitalize(), href=i)
33
34 return unicode(root).encode("utf-8")
35
36
37 def app(environ, start_response):
38 response_body = main(environ)
39 response_headers = [
40 ("Content-Type", "text/html; charset=UTF-8"),
41 ("Content-Length", str(len(response_body))),
42 ]
43 start_response("200 OK", response_headers)
44
45 return [response_body]