在服务器自定义表单系统上找不到 Flask 错误 URL

Flask Error Not Found URL On server custom Form System

嘿,我在 Flask 中制作了一个程序,让用户填写表格,然后它将通过电子邮件将该表格发送到特定的电子邮件。它以前工作得很好,但由于某种原因现在不是。这是我的代码:

@app.route('/application', methods=['POST', 'GET'])
def application():
    if request.method == 'POST':
        name = request.form["name"]
        github = request.form["github"]
        age = request.form["age"]
        location = request.form["location"]
        email = request.form["email"]
        discord = request.form["discord"]

        return redirect(f"/final/{name}/{github}/{age}/{location}/{email}/{discord}/")

@app.route('/final/<name>/<github>/<age>/<location>/<email>/<discord>/', methods=['GET','POST'])
def final(name, github, age, location, email, discord):
    mail= Mail(app)

    app.config['MAIL_SERVER']='smtp.gmail.com'
    app.config['MAIL_PORT'] = 465
    app.config['MAIL_USERNAME'] = 'prodatacollectors@gmail.com'
    app.config['MAIL_PASSWORD'] = '*******'
    app.config['MAIL_USE_TLS'] = False
    app.config['MAIL_USE_SSL'] = True
    b = Markup(f"Name: {name}\r\nGithub: {github}\r\nAge: {age}\r\nlocation: {location}\r\nemail: {email}\r\ndiscord: {discord}")
    msg = Message(f'Application {name}', sender = 'prodatacollectors@gmail.com', recipients = [email])
    msg.body = b
    mail.send(msg)
    return render_template("final.html" )

HTML 模板

  <form action="/application" method="POST">
            <p><input type = "text" name="name" placeholder="First And Last Name" /></p>
            <br><br>
            <p><input type = "text" name="github" placeholder="GitHub Profile Link" /></p>
            <br><br>
            <p><input type = "text" name="age" placeholder="Age" /></p>
            <br><br>
            <p><input type = "text" name="location" placeholder="State/Country" /></p>
            <br><br>
            <p><input type = "text" name="email" placeholder="Email" /></p>
            <br><br>
            <p><input type = "text"  name="discord" placeholder="Discord username and tag(if you have one)" /></p>
            <p><input type="submit"  value="Submit" /></p>
        </form>

我没有收到任何错误,它只是说请求的 url 在服务器上找不到

所以我找到了答案。所以 flask 不允许特定链接如 https://github.com/codingdudepy 作为重定向返回 url。由于某种原因,它也不允许# 之类的东西或.com 之类的域。当我删除这些东西时,它工作得很好。