问题
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.
回答1:
Look at quick start (A Minimal API, Resourceful Routing and etc.):
api.add_resource(HelloWorld, '/')
api.add_resource(TodoSimple, '/<string:todo_id>')
回答2:
I hope it helps
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'GET':
pass
elif request.method == 'POST':
pass
else:
pass
来源:https://stackoverflow.com/questions/19636532/flask-restful-api-urls