Flask Post方法405

问题描述 投票:1回答:1

为什么不调用Post方法,我只能使用get方法

@@ Admin.route(“ / upload-image”,methods = [“ GET”,'POST'])def upload_image():

if request.method == 'POST':

    if request.files:
        pdf = request.files["pdf"]

        print(pdf)
        return redirect()
return '''<form action="/Admin/upload-image" method='POST'>

    <div class="form-group">
      <label>Select PDF</label>
      <div class="custom-file">
        <input type="file" class="custom-file-input" name="pdf" id="pdf">
        <label class="custom-file-label" for="image">Select PDF</label>
      </div>
    </div>

    <button type="submit" class="btn btn-primary">Upload</button>
  </form>'''
python html flask
1个回答
0
投票

我在我的项目中遇到类似的问题,这是我找到的解决方案:-)

登录后致电

@app.route("/login", methods=['POST'])
def postCall():
 response = {}
 response['result'] = '0'
 response['messege'] = 'response from post'
 return response

获得登录电话

@app.route("/login", methods=['GET'])
   def getCall():
     response = {}
     response['result'] = '0'
     response['messege'] = 'response from get'
     return response
© www.soinside.com 2019 - 2024. All rights reserved.