龙卷风。怎么生的请求.正文?

2024-04-26 20:52:54 发布

您现在位置:Python中文网/ 问答频道 /正文

伙计们。我无法得到龙卷风的原始数据。我确实要求 curl -i localhost:8888 -d '{"a":12}'并期望在请求.正文,但收到了'{a:12}'。 源代码:

import tornado.web
import tornado.ioloop

class MainHandler(tornado.web.RequestHandler):
    def post(self):
        self.write(self.request.body)

if __name__ == "__main__":
    app = tornado.web.Application({
        (r"/", MainHandler)
    })
    app.listen(3000)
    tornado.ioloop.IOLoop.instance().start()

卷曲结果:

^{pr2}$

Python版本是3.4.2,Tornado版本是4.0.2


Tags: importself版本webapplocalhost原始数据源代码
2条回答

使用self.request.connection.stream.read_bytes直接读取数据流。在

Source

这是一个shell引用问题:shell正在删除命令curl 127.0.0.1:3000 -i -d {"a":12}中的引号。如果您引用-d的参数(您在问题的主体中是这样做的:curl -i localhost:8888 -d '{"a":12}',那么您应该得到您期望的结果。在

相关问题 更多 >