Skip to content

Commit 4d022b5

Browse files
author
zhangjie
committed
change api dir
1 parent b737195 commit 4d022b5

File tree

12 files changed

+85
-13
lines changed

12 files changed

+85
-13
lines changed

api/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def create_app():
1717
Config.init_app(app)
1818
db.init_app(app)
1919

20-
from .auth import api_auth as auth_blueprint
20+
from .resources.auth import api_auth as auth_blueprint
2121
app.register_blueprint(auth_blueprint, url_prefix='/api')
2222

23-
from .users import api_user as user_blueprint
23+
from .resources.users import api_user as user_blueprint
2424
app.register_blueprint(user_blueprint, url_prefix='/api')
2525

2626
return app
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from flask import Blueprint
2-
from ..app import api
3-
from .resources.login import LoginApi
4-
from .resources.logout import LogOutApi
2+
from api.app import api
3+
from .login import LoginApi
4+
from .logout import LogOutApi
55

66
api_auth = Blueprint('auth', __name__)
77

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from api.auth_token import token_auth
44
from api.errors import *
55

6-
from .resources.users import User
6+
from .users import User
77

88
api_user = Blueprint('users', __name__)
99

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flask_restful import fields, marshal_with, reqparse, Resource
2+
from api.models import User as UM
23

34

45
def valid_email(str):
@@ -16,17 +17,17 @@ def email(email_str):
1617
post_parser = reqparse.RequestParser()
1718
post_parser.add_argument(
1819
'username', dest='username',
19-
location='form', required=True,
20+
location='json', required=True,
2021
help='The user\'s username',
2122
)
2223
post_parser.add_argument(
2324
'email', dest='email',
24-
type=email, location='form',
25+
type=email, location='json',
2526
required=True, help='The user\'s email',
2627
)
2728
post_parser.add_argument(
2829
'user_priority', dest='user_priority',
29-
type=int, location='form',
30+
type=int, location='json',
3031
default=1, choices=range(5), help='The user\'s priority',
3132
)
3233

@@ -44,15 +45,22 @@ def email(email_str):
4445
}),
4546
}
4647

48+
user_f = {
49+
'username': fields.String,
50+
'uri': fields.Url()
51+
}
52+
4753

4854
class User(Resource):
4955

50-
@marshal_with(user_fields)
56+
@marshal_with(user_f)
5157
def post(self):
5258
args = post_parser.parse_args()
5359
# user = create_user(args.username, args.email, args.user_priority)
5460
print(args)
55-
return {}
61+
user = UM.query.first()
62+
return user
5663

64+
@marshal_with(user_f)
5765
def get(self):
58-
print('ok')
66+
return {}

api/users/resources/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)