0
我正在應用程序的前端工作。我需要從html模板發送刪除請求到服務器。刪除功能的工作原理如下:如何發送刪除請求到python服務器
def do_DELETE(self):
if re.match(r'\/product\/\d+', self.path): # match "/product/{ID}"
#send response code:
self.send_response(200)
#send headers:
self.send_header("Content-type:", "application/json")
# send a blank line to end headers:
self.wfile.write("\n")
#send response:
db.delete(re.search(r'[^/]*$', self.path).group(0)), self.wfile
return
我明白URL請求會,說,/product/2
。不過,我更熟悉節點的風格,例如:
<form id="delete-form" action="product/<%= product._id %>?_method=DELETE" method="POST">
<input type="submit" value="Delete">
</form>
我無法找到他們的方式在發送請求到服務器蟒蛇時,這將被處理。
我該如何發送一個url到python服務器中的刪除請求?