def render_front(self): tm, blogposts = db_model.blogpost.get_blog_list() template_values = {'home_page': const_and_params.get_page_home(), 'blogposts': blogposts, 'top_link_login': const_and_params.get_page_login(), 'top_link_signup': const_and_params.get_page_signup(), 'seconds_ago': int(round(time.time() - tm))} self.render('blogfront.html', **template_values)
def get(self, blog_id): tm, post = db_model.blogpost.get_by_id(blog_id) if not post: self.error(404) return template_values = {'home_page': const_and_params.get_page_home(), 'blogposts': [post], 'top_link_login': const_and_params.get_page_login(), 'top_link_signup': const_and_params.get_page_signup(), 'seconds_ago': int(round(time.time() - tm))} self.render('blogfront.html', **template_values)
def get(self): user_id = 0 user_id_hashed = self.request.cookies.get('user_id') if user_id_hashed: cookie_val = hashing.get_cookie(user_id_hashed) if cookie_val: user_id = int(cookie_val) if user_id == 0: # La forma buena de eliminar la cookie es tal y como está comentado, pero na valida el corrector de udacity #self.response.headers.add_header('Set-Cookie', 'user_id=deleted; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT') self.response.headers.add_header('Set-Cookie', 'user_id=; Path=/') self.redirect(const_and_params.get_page_signup()) else: user = db_model.user.User.get_by_id(user_id) if not user: self.error(404) return values = {self._tplv_username: user.username} self.render_front(self.set_template_values(values))
# -*- coding: utf-8 -*- import webapp2 from request_handlers.blog_main_page import BlogMainPage from request_handlers.newpost_main_page import NewpostMainPage from request_handlers.permalink_page import PermalinkPage from request_handlers.signup_page import SignupPage from request_handlers.welcome_page import WelcomePage from request_handlers.login_page import LoginPage from request_handlers.logout_page import LogoutPage import const_and_params app = webapp2.WSGIApplication([(const_and_params.get_page_home(), BlogMainPage), (const_and_params.get_page_new_post(), NewpostMainPage), (const_and_params.get_filter_post_permalink(), PermalinkPage), (const_and_params.get_page_signup(), SignupPage), (const_and_params.get_page_welcome(), WelcomePage), (const_and_params.get_page_login(), LoginPage), (const_and_params.get_page_logout(), LogoutPage)], debug=True) # http://joropi-hello-udacity.appspot.com/blog # http://joropi-hello-udacity.appspot.com/blog/signup # http://udacity-cs253.appspot.com/blog
def get(self): # La forma buena de eliminar la cookie es tal y como está comentado, pero na valida el corrector de udacity # self.response.headers.add_header('Set-Cookie', 'user_id=deleted; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT') self.response.headers.add_header("Set-Cookie", "user_id=; Path=/") self.redirect(const_and_params.get_page_signup())