Tôi mới vào khung Tornado. Khi tôi đặt loại tiêu đề application/pdf
, Tuy nhiên, chỉ cần MIME Type mặc định, tức là; plian/text
. Ở đây mã của tôi,Làm thế nào để xử lý loại MIME trong cơn lốc xoáy?
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())
Tải xuống thành công thông qua trình duyệt web. Ở đây url http: /203.193.173.102: 8888 /. Nhưng khi tôi mở tập tin pdf nó không được mở. Bất kỳ ai giúp tôi. Cảm ơn
Tại sao bạn mở 'requirement.txt' thay vì 'test.pdf'? – falsetru
Cảm ơn bạn đã trả lời. Tôi không biết cách đọc tập tin pdf trong cơn lốc xoáy. – dhana