It seems to me that it is feasible to use a POST request to delete data in Tornado from database:
def post(self, id):
# delete data from db using id
And on the client side, we can send a post request with the desired id for which content to be deleted. Is this a valid approach?
I notice that there is also a delete method in RequestHandler class in Tornado, but how should I use it properly? Some example would be helpful.
Unless i’m looking at an outdated exmplae it looks like tornado supports delete requests. http://www.tornadoweb.org/documentation/web.html
I would use the
deletemethod just like you’d use anything. Set up handler with the delete method (probably specifying andid) then delete that record if it exist and if user has appropriate permissions. I’ve never used Tornado but perhaps something like:If you are using javascript/jquery/ajax on the front to make the request the jquery ajax supports delete:
For your comment, you can just hit the url with the delete method.
/widgets/12From jquery documentation they say
http://api.jquery.com/jQuery.ajax/
Some stackoverflow posts suggest all modern browsers support the delete method.