import tornado.web import tornado.ioloop import tornado.options import tornado.httpserver from tornado.options import options from tornado.web import RequestHandler, url tornado.options.define('port', type=int, default=8000, help="服务器端口") class IndexHandler(RequestHandler): def post(self): # print(self.request.files) # 获取传递过来的文件属性 # print(self.request.files.keys()) # 可查看传递过来的文件名 # print(self.request.files['image']) # 获取文件 print(type(self.request.files['image'])) # 输出的类型是list self.write('OK!') if __name__ == '__main__': tornado.options.parse_command_line() app = tornado.web.Application([ (r'/', IndexHandler) ], debug=True) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.current().start()