设置 tornado 服务器的响应行和响应头
设置 tornado 服务器的响应行和响应头 from tornado . httpserver import HTTPServer from tornado . ioloop import IOLoop from tornado . options import define , parse_config_file , options from tornado . web import Application , RequestHandler define ( 'port' , type = int , default = 8888 , multiple = False ) parse_config_file ( 'config' ) class IndexHandler ( RequestHandler ) : def initialize ( self ) : '''get方法之前执行''' print ( 'initalize方法执行' ) def get ( self , * args , ** kwargs ) : self . write ( 'hello tornado' ) # self.set_status(404) # 设置响应头的状态码为404,但页面可以正常响应 self . set_status ( 777 , 'false code' ) #