【发布时间】:2014-05-09 18:22:13
【问题描述】:
我已经搜索了很长时间,但我找不到任何关于如何使用cherrypy 创建 HTTP 请求的文档。
我想实现这样的目标:
@cherrypy.expose
def index(self):
json = http_request("http://somesite/")
processed = process_json(json)
tmpl = env.get_template("template.html")
return tmpl.render(data=processed)
知道如何实现这一点吗?
【问题讨论】:
-
看看 python
requests库。见docs.python-requests.org/en/latest。 -
Cherrypy 用于服务请求而不是创建请求。您应该使用 urllib 或 requests 来发送 HTTP 请求。
标签: python httprequest cherrypy