Esempio n. 1
0
server.register('/', pages.index)
server.register('/allChess', pages.allChess)
server.register('/blog', pages.blog)
server.register('/random', pages.random)
server.register('/projects', pages.projects)
server.register('/login', authenticate.check_auth)
server.register('/logout', authenticate.logout)
server.register('/admin', pages.admin)
server.register('/sub_post', blog.sub_post)
server.register('/del_post', blog.del_post)

T = template.Loader("/home/brendan/Website/HTTP/templates", autoescape=None)

#Registers all blog posts in their own page
blog_pages = []
for i in database.read_posts()[::-1]:
    blog_pages.append(i)
    server.register(
        "/" + str(i[0]), lambda response: response.write(
            T.load("post_page.html").generate(
                **{
                    "title": "{} - BrendanR".format(i[1]),
                    "post": blog_pages[int(response.request.uri[1:]) - 1]
                })))
    #I wonder if there is a better way of doing this? ^ It is pretty neat though <3

#Registers all static (no templating) pages in their own page
#Was loading the pong page for both fireworks and pong, weird.
#for i in os.listdir("/home/brendan/Website/HTTP/templates/static"):
#    server.register("/"+i[:-5], lambda response: response.write(
#		T.load("static/{}".format(i)).generate(**{}))
Esempio n. 2
0
def blog(response):
    T.reset()
    args["posts"] = database.read_posts(-1)
    args["title"] = "Blog - BrendanR"
    response.write(T.load("blog.html").generate(**args))
Esempio n. 3
0
def blog(response):
    T.reset()
    args["posts"] = database.read_posts(-1)
    args["title"] = "Blog - BrendanR"
    response.write(T.load("blog.html").generate(**args))
Esempio n. 4
0
def index(response):
    T.reset()
    args["post"] = database.read_posts(1)[0]
    args["title"] = "BrendanR"
    response.write(T.load("index.html").generate(**args))
Esempio n. 5
0
def index(response):
    T.reset()
    args["post"] = database.read_posts(1)[0]
    args["title"] = "BrendanR"
    response.write(T.load("index.html").generate(**args))