from flask import Flaskflask
app = Flask(name)app
from flask import views函數
class Login(views.MethodView):
# 405 Method Not Allowd 不被容許的請求方式
def get(self):
return "get 200 ok"post
def post(self): return "post 200 ok"
app.add_url_rule("/login", view_func=Login.as_view(name="login"))url
if name == 'main':
app.run()code