Flask 宁静的 API 网址 [英] Flask restful API urls
本文介绍了Flask 宁静的 API 网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Flask-RESTful(http://flask-restful.readthedocs.org/en/latest/index.html) 在我的项目中.阅读一些示例后,我了解到我的 Resource 类中只有 get、post、update 等方法.如何使用唯一的 url 制作我自己的 Resource 类方法,就像在 Flask 中使用 @app.route() 装饰器一样?谢谢.
I am using Flask-RESTful(http://flask-restful.readthedocs.org/en/latest/index.html) in my project. Afrer reading some examples I understood that I will have only get, post, update etc methods in my Resource class. How can I make my own Resource class method with a unique url like it was in Flask with @app.route() decorator? Thanks.
推荐答案
看快速入门 (一个最小的 API,Resourceful Routing 等):
Look at quick start (A Minimal API, Resourceful Routing and etc.):
api.add_resource(HelloWorld, '/')
api.add_resource(TodoSimple, '/<string:todo_id>')
这篇关于Flask 宁静的 API 网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文