孤独的素数 2020-07-23 00:55 采纳率: 0%
浏览 181

flask用action无法跳转

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 -

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-07-31 09:31
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#网络安全#的问题:求ensp的网络安全,不要步骤要完成版文件
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥20 使用Photon PUN2解决游戏得分同步的问题
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM