- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
出于某种原因,当我从 jQuery (1.4.4) 向 CherryPy 服务器 (3.1.2) 发出 DELETE HTTP 请求时,没有发送任何参数。 POST、GET 和 PUT 请求可以正常发送参数。
这是 CherryPy 服务器代码:
import cherrypy
class DeleteExample(object):
exposed = True
def PUT(self, *args, **kwargs):
print kwargs
def DELETE(self, *args, **kwargs):
print kwargs
global_conf = {'global': {'server.socket_port': 8080},
'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
'tools.staticdir.root': '/home/kevin/workspace/delete_example',
'tools.staticdir.on': True,
'tools.staticdir.dir': 'src',
'tools.staticdir.index': 'index.html'}
}
cherrypy.quickstart(DeleteExample(), config=global_conf)
这是带有 jQuery 代码的 index.html:
<html>
<head>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script>
$(document).ready(function() {
$.ajax({
type: "PUT",
url: "http://localhost:8080",
dataType: "json",
data: {first: 10, second: 200}
});
$.ajax({
type: "DELETE",
url: "http://localhost:8080",
dataType: "json",
data: {first: 10, second: 200}
});
});
</script>
</head>
<body>
</body>
</html>
这是从 CherryPy 网络服务器打印出来的内容:
{'second': '200', 'first': '10'}
127.0.0.1 - - [23/Jan/2011:04:02:48] "PUT / HTTP/1.1" 200 19 "http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13"
{}
127.0.0.1 - - [23/Jan/2011:04:02:51] "DELETE / HTTP/1.1" 200 19 "http://localhost:8080/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.04 (lucid) Firefox/3.6.13"
如您所见,使用 .ajax 函数发出的 PUT 和 DELETE 请求除了类型外完全相同。但是,出于某种原因,PUT 发送所有参数,而 DELETE 不发送任何参数。
有人知道为什么 DELETE 请求没有发送正确的参数吗?
最佳答案
您似乎正在尝试发送带有请求正文的 DELETE 请求,这...不寻常。 (同样适用于 GET)。
关于jquery - 从 jQuery 到 CherryPy 的 DELETE 请求不发送参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4772135/
假设我有一些代码(使用 CherryPy),如下所示: import cherrypy class Names: def index(self, name=None): ret
{% if bCat2 == True %} True {% else %} False 返回 False即使 bCat2是 True . 谢谢, 安德鲁 最佳答案 选项 1:最常见的
我这里有一个Python程序。它使用 CherryPy 创建服务器。 # coding:utf-8 import os.path import cherrypy from app import app
我有一个现有的cherrypy应用程序,但我想知道是否可以在gevent wsgi服务器上运行它。我想我可以,但我无法访问 Linux 服务器来测试 gevent,并且无法让它在我的 Mac 上运行。
当我使用cherrypy.tree.mount时,我无法从系统连接到在docker容器中运行的CherryPy服务器,但是当我执行cherrypy.quickstart()时,我可以连接至服务器。对带
我开始学樱桃,但是遇到了路障。我无法获取静态文件来挽救生命。我正在搜索404。The path '/static' was not found.,但是尚未找到解决方案。我要做的就是在http://lo
运行 CherryPy 应用程序时,它会发送服务器名称标签,例如 CherryPy/version。 是否可以在不修改 CherryPy 的情况下从应用程序重命名/覆盖它,以便它显示其他内容? 也许像
CherryPy 服务器将其错误日志写入何处?我已经安装了 CherryPy 并使用 python3.2 启动了服务器 from cherrypy import wsgiserver
我正在开发一个 django 应用程序,我使用cherrypy作为服务器。 Cherrypy 为每个页面 View 创建一个新线程。我希望能够从它们中的任何一个中访问所有这些线程(负责与 django
这个问题在这里已经有了答案: 8年前关闭。 Possible Duplicate: Using mappings in CherryPy 我如何将 url regEx(例如/data/[A-Z].tx
我知道这个问题比“如何加快我的网站的速度”要高出一个步骤,但是我到处都是由Cherrypy驱动的网站,却找不到任何电子商务网站。在开始重写当前站点之前,我们开始使用Cherrypy和jinja2作为概
我有一个cherrypy api,旨在在服务器上运行很长时间。 我有一个不可靠的客户端,它可能会因我无法控制的各种原因而终止或关闭连接。 在我的服务器 api 运行期间,我想定期检查连接状态,确保客户
这是我第一次使用 CherryPy,所以请原谅任何愚蠢的行为。 我正在尝试编写一个 RESTful API,该 API 部分处理添加/删除人员。我希望能够 GET/PUT/DELETE example
我想在不同的端口和不同的应用程序上运行 2 个cherry py 服务器。 我设法运行它们,但是如何在应用程序和服务器之间连接?我希望能够去 http://127.0.0.1:3141/ 并获取ser
有没有办法让 CherryPy 响应包含句点的 url,例如 http://some/base/path/oldscript.py ?我有许多像这样调用的旧 CGI 脚本,我正在尝试将它们整合到一个漂
使用 Cherrypy 如何制作此脚本以便任何 url 都将加载 load index.html 示例,如果使用其中任何一个,那么它们都会加载index.html页面www.mtsite.test/1
我尝试从具有 Transfer-Encoding: chunked header (没有 Content-Length)的 POST 正文中获取数据。内容类型是application/octet-st
我正在构建一个使用 CherryPy 提供 REST API 的应用程序,以及另一个执行后台工作的线程(实际上,它从串行端口读取数据)。 import cherrypy import threadin
我向 CherryPy 服务器添加了摘要身份验证,我想知道撤销用户身份验证的标准是什么,并提示他们再次输入凭据。删除 cookie 不会强制出现提示,但使用隐身或其他浏览器会强制出现提示。 我的配置:
我在启动 CherryPy 时遇到一些问题,我不明白为什么我总是收到此错误。这是版本和带有日志输出的相关代码。Python 2.7.6CherryPy 3.5.0(通过 PIP) CURRENT_DI
我是一名优秀的程序员,十分优秀!