Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

这样写有点意思 #6

Open
misakar opened this issue Dec 4, 2016 · 3 comments
Open

这样写有点意思 #6

misakar opened this issue Dec 4, 2016 · 3 comments

Comments

@misakar
Copy link

misakar commented Dec 4, 2016

https://github.com/Muxi-Studio/guisheng_be/blob/master/guisheng/app/api_1_0/everydaypic.py#L11
你这里的写法很lowlevel啊, 其实可以直接用现成的jsonify函数, 用Response对象封装不多见, 虽然也可以.

@misakar
Copy link
Author

misakar commented Dec 4, 2016

其实可以这么做, jsonify只能处理字典, 似乎处理列表这些用Response封装是唯一办法了.

@RoseOu
Copy link
Collaborator

RoseOu commented Dec 5, 2016

因为有些别的地方要处理列表,所以用不了jsonify,然后想了很久没想到别的方法...然后为了统一这里也这么写了。 @neo1218

@misakar
Copy link
Author

misakar commented Dec 5, 2016

@RoseOu 其实你可以写成装饰器,感觉这样更好 比如

@app.route('/)
@admin_required
@jsonify
def function():
      return [{......}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants