# coding=utf8
import tornado.web
from tornado import ioloop
"""
Python获取请求中的参数
"""
class TestHandler(tornado.web.RequestHandler):
def post(self):
# 获取post请求实体的参数
a = self.request.body
print "请求实体参数----"
print a
print "---------------"
# 获取url传参或者form表单的参数
b = self.get_argument("name")
print b
self.write(b)
def make_app():
return tornado.web.Application([(r"/static/(.*)"
, tornado.web.StaticFileHandler, dict(path="static"))
, (r"/test", TestHandler)
])
if __name__ == "__main__":
app = make_app()
app.listen(8080)
tornado.ioloop.IOLoop.current().start()
结果示例:
|