Пример #1
0
    def get(self):
        posts = BlogPost.get_all()
        results = []

        for post in posts:
            obj = post.to_json()
            results.append(obj)
        return results
Пример #2
0
    def home():
        posts = BlogPost.get_all()
        results = []

        for post in posts:
            obj = {
                "id": post.id,
                "title": post.title,
                "content": post.content,
                "date_created": post.date_created,
                "date_modified": post.date_modified
            }
            results.append(obj)
        response = jsonify(results)
        response.status_code = 200
        return response