Exemplo n.º 1
0
    def get(self):

       user = users.get_current_user()

       

       if not user:
          self.redirect(users.create_login_url(self.request.uri))
       else:

           template_values = {
              'user': user.email()
           }
    
           template_engine = TemplateEngine()
           self.response.out.write(template_engine.render('home.html', template_values))
Exemplo n.º 2
0
    def do_get(self, request):
        super().do_get(request)
        # print("self.path", self.path)
        # if self.path in ["blog", "blog/", "/", ""]:
        #     self.response = Response(main.protocolVersion, States.OK)
        #     self.response.body = replace_engine.set_top_page(main.DOCUMENT_ROOT + "/blog_top.html")
        #     self.ext = "html"

        #     return self.response

        head, tail = os.path.split(self.path)
        print("tail",tail)
        self.root, self.ext = os.path.splitext(tail)
        self.ext = self.ext.lstrip(".")
        print(self.ext)
        print(bool(self.ext))
        if self.ext:
            normal = NormalController()
            return normal.do_get(request)

        if tail and not tail == "blog":
            print("in article")
            article = articles.get_articles(tail)

            if article:
                engine = TemplateEngine(article, "template")
                self.response = Response(main.protocolVersion, States.OK)
                self.response.body = engine.render()
                self.ext = "html"

            else:
                self.response = self.not_found()

        else:
            print("in blog_top")
            self.response = Response(main.protocolVersion, States.OK)
            self.response.body = replace_engine.set_top_page(os.path.join(main.DOCUMENT_ROOT, "blog_top.html"))
            self.ext = "html"

            # return self.response
            # self.response = Response(main.protocolVersion, States.Not_Found)
            # self.response.body = os.path.join(main.DOCUMENT_ROOT, "blog.html")
            # self.ext = "html"

        return self.response
Exemplo n.º 3
0
    def get(self):

        template_engine = TemplateEngine()
        self.response.out.write(template_engine.render('main.html', []))
Exemplo n.º 4
0
    def get(self):

       template_engine = TemplateEngine()
       self.response.out.write(template_engine.render('main.html', []))