def post(self, pid): title = self.request.get("title") content = self.request.get("content") tags = self.request.get("tags") t = tags.split() if tags else [] Posts.edit_post(pid, title, content, t) self.redirect("/")
def post(self): title = self.request.get("title") content = self.request.get("content") tags = self.request.get("tags") if title and content: url_date = datetime.now().strftime("%Y-%m-%d") url_title = str(title).translate(string.maketrans("",""), \ string.punctuation) url = url_date + "/" + url_title.lower().replace(" ","-") #content = content.replace("\n", "<br>") # preserve paragraphs t = tags.split() if tags else [] Posts.add_post(url, title, content, t) self.redirect("/p/"+url) else: self.write("error posting") return
def get(self, pid): p = Posts.get_post(pid) self.render_page(p.get()) if p else self.redirect("/newpost")
def get(self,pid): p = Posts.get_post(pid) self.render_page(p) if p else self.redirect("/404")
def render_page(self): posts = Posts.get_posts() self.render("blogfront.html",posts=posts, message="")