上QQ阅读APP看书,第一时间看更新
How it works...
We know that by default, any Flask view function supports only GET requests. The same applies to class-based views. In order to support or handle any other kind of request, we have to specifically tell our class, via a class attribute called methods, about the HTTP methods we want to support. This is exactly what we did in our last example of GET/POST requests.
For GET requests, the request object will look for args, that is, request.args.get(), and for POST, it will look for form, that is, request.form.get().
Also, if we try to make a GET request to a method that supports only POST, the request will fail with a 405 HTTP error. The same holds true for all the methods.