-
Notifications
You must be signed in to change notification settings - Fork 1
Check method
Astremy edited this page Feb 3, 2020
·
1 revision
The user can access to the page with multiple request methods. (GET, POST, PUT...) You can check the method with need the argument "user" in your function. user.request.method is the method of the request.
You can also use the decorator "methods" to only allow the methods you want
@site.path("/")
def index(user):
return f"You access to this url with the {user.request.method} method !"
@site.path("/connect")
@methods("GET","POST")
def connect(user):
if user.request.method == "GET":
return "We can send the form to connect"
else:
return "We can verity if your logins are correct"