Return HTTP status code 201 in flask

前端 未结 9 1160
忘掉有多难
忘掉有多难 2020-12-23 19:58

We\'re using Flask for one of our API\'s and I was just wondering if anyone knew how to return a HTTP response 201?

For errors such as 404 we can call:



        
9条回答
  •  我在风中等你
    2020-12-23 20:46

    you can also use flask_api for sending response

    from flask_api import status
    
    @app.route('/your-api/')
    def empty_view(self):
        content = {'your content here'}
        return content, status.HTTP_201_CREATED
    

    you can find reference here http://www.flaskapi.org/api-guide/status-codes/

提交回复
热议问题