Example #1
0
 def get(self):
     posts_obj = PostModel.find_all_posts()
     if posts_obj:
         posts = [post.json() for post in posts_obj]
         response = jsonify({'post': posts})
         response.headers.add('Access-Control-Allow-Origin', '*')
         return response
     else:
         return {'message': 'No posts found!'}, 404
Example #2
0
def index():
    posts = PostModel.find_all_posts()
    return render_template('blog/index.html', posts=posts)
Example #3
0
def allPosts():
    return {
        "posts": post_schema.dump(PostModel.find_all_posts(), many=True)
    }, 200