[英]Bottle and Python. Change format of a static_file while downloading
Good afternoon.下午好。 I am trying to download a file with bottle.我正在尝试用瓶子下载文件。 But it always downloads it with a .html format.但它总是以 .html 格式下载它。 How can i change it to a .txt?如何将其更改为 .txt? Thank you very much.非常感谢。 My code is the following:我的代码如下:
@get('/api/v1/descargarHist/<id>')
def descargar (id):
directorio, fichero = Repo.recuperar_historial(id)
return static_file(fichero, root=directorio,download='{}.txt'.format(id))
No matter how much i try, i can't change it.无论我怎么努力,我都无法改变它。 It always downloads it as a .html Is there a way to do this?它总是将其下载为 .html 有没有办法做到这一点?
static_file
采用mimetype
参数:
return static_file(fichero, root=directorio, download='{}.txt'.format(id), mimetype='text/plain')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.