-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogus.py
executable file
·46 lines (37 loc) · 1.56 KB
/
blogus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import utils
import config
def run(appserver):
"""
Wrapper to finally make call to the Application
"""
urlhandler = UrlHandler(appserver)
class UrlHandler(object):
""" url mapping service """
def __init__(self, appserver):
""" store request headers """
# all root level static files goes here
if appserver.request.pathurl in ("/favicon.ico", "/robots.txt"):
appserver.response.set_header({
"Location":"%s%s" % (appserver.context["site_cdn_path"],
appserver.request.pathurl),
})
appserver.response.set_code(301)
else:
if appserver.request.pathurl == "/":
context = appserver.context
context.update({"page_content": "nothing",
"page_title": "Home"})
appserver.response.render(context=context, view="home")
elif appserver.request.pathurl.startswith("/list"):
context = appserver.context
context.update({"page_content": "nothing",
"page_title": "List"})
appserver.response.render(context=context, view="list")
else:
context = appserver.context
context.update({"page_content": "nothing",
"page_title": "There is nothing like Python"})
appserver.response.render(context=context, view="post")