user2928288
user2928288

Reputation: 51

Flask restful API urls

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.

Upvotes: 2

Views: 3097

Answers (2)

Liam
Liam

Reputation: 18

I hope it helps

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'GET':
        pass
    elif request.method == 'POST':
        pass
    else:
        pass

Upvotes: -2

tbicr
tbicr

Reputation: 26050

Look at quick start (A Minimal API, Resourceful Routing and etc.):

api.add_resource(HelloWorld, '/')

api.add_resource(TodoSimple, '/<string:todo_id>')

Upvotes: 4

Related Questions