|
1 | | -from flask_restful import Resource, reqparse, abort |
| 1 | +from flask_restful import Resource, abort |
2 | 2 | from flask import request |
3 | 3 | from app.models.blog import Blog |
4 | 4 | from app.services.blog_service import BlogService |
5 | 5 |
|
6 | 6 | blog_service = BlogService() |
7 | 7 |
|
| 8 | + |
8 | 9 | def register_view(api): |
9 | 10 | api.add_resource(BlogListApi, '/api/blogs') |
10 | 11 | api.add_resource(BlogApi, '/api/blogs/<int:id>') |
@@ -42,36 +43,10 @@ def put(self, id): |
42 | 43 | def delete(self, id): |
43 | 44 | return blog_service.delete(id) |
44 | 45 |
|
45 | | - # def __init__(self): |
46 | | - # validation example |
47 | | - # self.reqparse = reqparse.RequestParser() |
48 | | - # self.reqparse.add_argument('title', type = str, location = 'json', required = True, |
49 | | - # help = 'No title provided') |
50 | | - # self.reqparse.add_argument('description', type = str, location = 'json', required = True, |
51 | | - # help = 'No description provided') |
52 | | - # self.reqparse.add_argument('blog_id', type = int, location = 'json') |
53 | | - |
54 | 46 |
|
55 | 47 | class DummyBlogs(Resource): |
56 | 48 | def post(self): |
57 | 49 | num = int(request.data.decode("utf-8")) |
58 | 50 | from app.celery.celery_worker import add_dummy_blogs |
59 | | - add_dummy_blogs.apply_async(args=[num, 10], countdown=10) |
| 51 | + add_dummy_blogs.apply_async(args=[num], countdown=10) |
60 | 52 | return success_response() |
61 | | - |
62 | | -# Routes approach to create api |
63 | | -# @app.route('/') |
64 | | -# @app.route('/index') |
65 | | -# def index(): |
66 | | -# user = {'username': 'Saurabh'} |
67 | | -# posts = [ |
68 | | -# { |
69 | | -# 'author': {'username': 'John'}, |
70 | | -# 'body': 'Beautiful day in Portland!' |
71 | | -# }, |
72 | | -# { |
73 | | -# 'author': {'username': 'Susan'}, |
74 | | -# 'body': 'The Avengers movie was so cool!' |
75 | | -# } |
76 | | -# ] |
77 | | -# return render_template('index.html', title='Home', user=user, posts=posts) |
0 commit comments