在某个GET
请求中,我需要根据请求中的参数在本地读取文件,并将其发送到请求的输入流中。我该怎么做?
class GetArchives(tornado.web.RequestHandler):
def get(self, param1, param2):
path = calculate_path(param1, param2)
try:
f = open(path, 'rb')
# TODO: send this file to request's input stream.
except IOError:
raise tornado.web.HTTPError(404, 'Invalid archive')