def user_posts_filter(): """ Retrive posts associated with a (filter) paramters: tags & name If no paramters, returns all posts :return: """ try: tags = request.headers.get("tags") name = request.headers.get("name") if tags is None and name is None: posts = post.get_posts() else: posts = post.get_post_tag_name( tags=tags, name=name ) response_json = json_dict(posts, indent=4, default=str) return Response(response_json, status=success_code, mimetype='application/json') except Exception as e: print(e) return response_unknown()
def course(self,board,message=None): if cherrypy.request.method == 'POST': if not message: print('No message received') pass #Add to errors or something... else: #adds a post self.add_post(message) #Connect and load posts self.posts = p.get_posts(self.board_name) if not self.in_course_list(board): return "whatever." # pass self.board_name = board name_space = {'posts':p.get_posts(board),'course':board} return str(Template(self.index_template, name_space))
def __init__(self,board_name="FroSci"): self.board_name = board_name #Connect and load posts self.posts = p.get_posts(self.board_name) self.get_database() #load templates index_t = open('templates/index.tmpl', 'r') expand_t = open('templates/expand.tmpl', 'r') homepage_t = open('templates/homepage.tmpl', 'r') suggest_t = open('templates/suggest.tmpl', 'r') #string-ize self.expand_template = expand_t.read() self.index_template = index_t.read() self.homepage_template = homepage_t.read() self.suggest_template = suggest_t.read()
def blog_index(): return bottle.template('blog_template', post.get_posts())