安装bottle库
pip install bottle
上传代码
import bottle
@bottle.get('/upload')
def upload_get():
return bottle.static_file('index.html', 'd:/web')
@bottle.post('/upload')
def upload_post():
filename = bottle.request.forms.get('filename')
data = bottle.request.files.get('file')
data.save('d:/web/' + filename, overwrite=True)
bottle.run(host='127.0.0.1', port=80)
静态文件index.html
<html>
<head>
<title>文件上传</title>
</head>
<body>
<div>
<form action"/upload" method="post" enctype="multipart/form-data">
文件名: <input type="text" name="filename"><br/>
文件: <input type="file" name="file"><br/>
<input type="submit" value="上传" />
</form>
<div>
</body>
</html>
标签:文件,get,upload,filename,bottle,上传
From: https://www.cnblogs.com/xiadongzhi/p/16727250.html