Route view class
from flask import Flask
app = Flask(name)
View class
Views of source file to see views inherit the last class
Introducing the base view class of the CBV
from flask import views
Base class inherits view CBV
the Login class (views.MethodView):
# 405 Not allowd Method, impermissible request method
DEF GET (Self):
return "200 is OK GET"
def post(self):
return "post 200 ok"
Classes are added to the view route; view_func = Login.as_view view function will be converted into the view class Login
app.add_url_rule("/login", view_func=Login.as_view(name="login"))
if name == 'main':
app.run()