from flask import Flask,request
app = Flask(__name__)
@app.route('/')
def index():
print('index')
html = """
license recoginition index page
上传图片
人脸检测
人脸识别
"""
return html
@app.route('/load_img')
def load_img():
html = """
upload image file
"""
return html
@app.route("/upload_img_file",methods=["GET"])
def upload_img_file():
print('img')
print(request.files['img'])
return "upload_img_file"
from flask import Flask,request
app = Flask(__name__)
@app.route('/')
def index():
print('index')
html = """
<html>
<head>
<title>license recoginition index page</title>
</head>
<body>
<center>
<a href="/load_img">上传图片</a><br/><br/>
<a href="/face_check">人脸检测</a><br/><br/>
<a href="/face_recog">人脸识别</a><br/><br/>
</center>
</body>
</html>
"""
return html
@app.route('/load_img')
def load_img():
html = """
<html>
<head>
<title>upload image file</title>
</head>
<body>
<form action"/upload_img_file" method="post" enctype="multipart/form-data">
<input type="file" name="img" value="img">
<input type="submit" value="upload image">
</form>
</body>
</html>
"""
return html
@app.route("/upload_img_file",methods=["GET"])
def upload_img_file():
print('img')
print(request.files['img'])
return "upload_img_file"
代码和网页效果如上,我点击了upload image后,按道理应该要跳转到upload_img_file,但是却任然停留在http://127.0.0.1:5000/load_img上,报错Method Not Allowed
The method is not allowed for the requested URL.127.0.0.1 - - [23/Jul/2020 00:52:05] "POST /load_img HTTP/1.1" 405 -