GET, PUT, POST in Custom method

How to create and define custom methods with different HTTP Method in my own custom app?

Let’s say I have 3 methods:

  1. method X
  2. method Y
  3. method Z

I want method X to be accessed by POST method.
I want method Y to be accessed by PUT method.
I want method Z to be accessed by GET method.

Thanks @pithiya_Nilesh ,
I’m using this code :

@frappe.whitelist()
def methodname():
msg = “”
if frappe.request.method == “POST”:
#action 1
msg = “post”
elif frappe.request.method == “PUT”:
#action 2…
msg = “put”
else:
msg = “get”
return {“data” : msg}

1 Like