【发布时间】:2017-06-01 02:12:15
【问题描述】:
我正在开发应用程序的前端。我需要从 html 模板向服务器发送删除请求。删除功能的工作原理如下:
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>
在将请求发送到 python 服务器时,我无法找到他们的处理方式。
如何向 python 服务器中的删除请求发送 url?
【问题讨论】:
标签: javascript python html request