HTTP method methods=['GET','POST'] in python flask

HTTP has many URL methods.
The default route only responds to GET requests, but we can pass the methods parameter
in the decorator app.route to change the request method,

@app.route('/login/',methods=['GET','POST'])
@app.route('/login/<id>',methods=['GET','POST'])

If GET exists, the HEAD method will also be added automatically.
Since Flask0.6, automatic processing of OPTIONS has also been realized.

HTTP methods and usage scenarios:

GET: Get resources, GET operations should be idempotent

HEAD: Want to get information, but only care about the message header. The application should handle it like a GET request, but without returning actual content

POST: create a new resource

PUT: Completely replace or create a resource. Although the PUT operation has side effects, it should also be idempotent.

DELETE: delete resource. DELETE operations have side effects, but are also idempotent.

OPTIONS: Get the HTTP methods supported by the resource.

PATCH: Partial update, modifying an existing resource.

Welcome to the (Q) group to help you solve problems:
insert image description here

Guess you like

Origin blog.csdn.net/m0_38124502/article/details/78680498