我正在尝试从表单将文件上传到Flask服务器。我的HTML(我正在使用React)如下:
<form action="/" method="get">
<input type="file" id="placesCSV" name="placesCSV"></input>
<input type="submit" />
</form>
但是以下是python中的代码:
@app.route('/', methods = ['GET'])
def findRoutes():
if request.method == 'GET':
print(request.args)
print(request.files)
正确打印request.args
的文件名,但request.files
为空。
我认为您应该将request.method更改为POST