Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 即使指定了POST,Flask也返回405方法不允许_Python_Flask - Fatal编程技术网

Python 即使指定了POST,Flask也返回405方法不允许

Python 即使指定了POST,Flask也返回405方法不允许,python,flask,Python,Flask,当上传到我的上传文件路径时,我收到一个405方法不允许的错误。我已经指定路由接受GET和POST方法,所以我不确定它为什么不工作 @app.route'/upload',methods=[GET,POST] def上传文件: 如果request.method==“GET”: 返回render_templatehome.html elif request.method==“POST”: 如果“文件”不在request.file中: 返回render_templatehome.html file=r

当上传到我的上传文件路径时,我收到一个405方法不允许的错误。我已经指定路由接受GET和POST方法,所以我不确定它为什么不工作

@app.route'/upload',methods=[GET,POST] def上传文件: 如果request.method==“GET”: 返回render_templatehome.html elif request.method==“POST”: 如果“文件”不在request.file中: 返回render_templatehome.html file=request.files['file'] 如果file.filename==: 返回render_templatehome.html 如果文件和允许\u filefile.filename: filename=secure\u filenamefile.filename 转换文件=转换文件 返回render_templatehome.html,converted_file=converted_file,img_src=UPLOAD_FOLDER+filename 应该是:

@app.route('/upload', methods=["GET", "POST"])
您给出的是一个包含一个字符串GET、POST的列表,而不是一个包含两个字符串GET和POST的列表

附言: 如下所述:

不要在生产设置中使用运行。它不是为了满足生产服务器的安全性和性能要求。相反,请参见WSGI服务器建议的部署选项


请阅读

多么愚蠢的错误!谢谢我会试试这个。另外,在所描述的部署方法中,哪种方法最容易配置?如果我想更改服务器,推送新文件是唯一的方法吗,还是…?这取决于您的需要。Heroku和Pythony似乎更简单。但是如果你需要更具弹性的东西,并且你知道你在做什么,AWS、Azure、GCP会更好,但它们需要更多的技能。
@app.route('/upload', methods=["GET", "POST"])