I new in web.py, and I try to create a download command.
I create this one:
import web
urls = (
'/', 'index',
'/download', 'Download'
)
class index:
def GET(self):
return "Hello, world!"
class Download:
def GET(self):
path = 'http:\\localhost:8080\C:\11\229077_6482396906_558_n.jpg'
web.header('Content-Disposition', 'attachment; filename="fname.ext"')
web.header('Content-type','images/jpeg')
web.header('Content-transfer-encoding','binary')
return open(path, 'rb').read()
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
and I have two main problems:
When I enter to
http://localhost:8080/download
, it gives me 500 internal Server Error. Why?I cant choose which file I would like to download (just change the path argument manually). How I give to this function external argument?