def search(): pattern = request.form.get('pattern') result = Database.find(constants.POST_COLLECTION, {"author": { "$regex": u"{}".format(pattern) }}) li = [r for r in result] return render_template('search.html', posts=li, author=pattern)
def from_blog(uid): return [ post for post in Database.find(collection=constants.POST_COLLECTION, query={'blog_id': uid}) ]
def find_by_author_id(cls, author_id): all_blog = Database.find(constants.BLOG_COLLECTION, {"author_id": author_id}) return [cls(**blog) for blog in all_blog]
def home(): posts = Database.find(constants.POST_COLLECTION, {}) return render_template('home.html', blogs=[post for post in posts])