#!"C:\usr\local\Python23\python.exe"
import sys
import os
class DownloadFile:
def do(self, file):
sys.stdout.write("Content-Type: application/octet-stream\n")
sys.stdout.write("Content-Disposition: attachment; filename=\"" + os.path.basename(file) + "\"\n")
sys.stdout.write("Content-Length: " + str(os.path.getsize(file)) + "\n")
sys.stdout.write("Expires: 0\n")
sys.stdout.write("Cache-Control: must-revalidate, post-check=0,pre-check=0\n")
sys.stdout.write("Pragma: private\n")
sys.stdout.write("\n")
if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
myfile = open(file,'rb')
sys.stdout.write(myfile.read())
myfile.close()
r = DownloadFile()
r.do('c:\\okinawa.csv')
良かったらクリックお願いします→
