def get(self): self.response.headers["Content-Type"] = "application/json; charset=UTF-8" if not self.user_cookie: self.redirect("/login") else: post_obj = PostsDb.get_all() json_post = Json() for post in post_obj: sub = post.subject cont = post.content created = post.created.strftime("%b %d, %Y") last_time = post.last_created.strftime("%b %d, %Y") json_post.set_variables(sub, cont, created, last_time) json_post.make_json_str() self.write(json_post.get_json())
def get(self): if self.user_cookie: posts = PostsDb.get_all() self.render("/posts.html", user=self.user_cookie, posts=posts) else: self.redirect("/login")