【发布时间】:2013-08-21 10:00:12
【问题描述】:
我是 Tornado 框架的新手。当我设置标题类型application/pdf时,但它只需要默认的MIME类型,即; plian/text。这是我的代码,
class MainHandler(tornado.web.RequestHandler):
def get(self):
ifile = open("requirements.txt", "r")
self.set_header('Content-Type', 'application/pdf; charset="utf-8"')
self.set_header('Content-Disposition', 'attachment; filename="test.pdf"')
#print(self.list_headers())
self.write(ifile.read())
通过网络浏览器下载成功。这里网址 http://203.193.173.102:8888/。 但是当我打开pdf文件时它没有打开。任何人帮助我。谢谢
【问题讨论】:
-
你为什么打开
requirement.txt而不是test.pdf? -
感谢您的回复。我不知道如何在龙卷风中阅读 pdf 文件。