简体   繁体   中英

Flask & HTML, form not Submitting

Website Link: Click Me

The " Next " button isn't submitting. My HTML Code is:

{% extends "layout.html" %}
{% block main %}
<div style='float:left;width:70%;'>
<div style='margin-top:200px;'>
<form method='POST' action='/login1'>
<input type='hidden' value="{{path}}">
<input style='width:800px;height:60px;font-size: 2em;' type='email' placeholder='Type your email to continue...' name='email' value="{{name}}">
<style>
  .sub:hover{
    border-style:none;
  }
  .sub{
    border-style:none;
  }
</style>
<input class='sub' type='submit' value='Next' style='height:75px;'>
</form>
</div>
</div>
<div style='float:left;width:20%;'>
<!--<img height="100%" src='static/assets/AccountBanner.png'>!-->
</div>
{% endblock %}

My Python Flask code is:


@app.route('/login')
def login():
    username = request.cookies.get('login')
    psw = request.cookies.get('psw')
    if 'login' in request.args.get('path'):
        return redirect('/login?path=/')
    if username == None:
        return render_template('login/index.html',path = request.args['path'])
    with open('static/json/members.json') as a:
        a = json.load(a)
    found = False
    for i in a:
        if i["email"] == username:
            if str(i["password"]) != str(psw):
                return redirect('/')
            else:
                found = True
    if found == False:
        return render_template('login/index.html',path=request.args['path'])
    return redirect('/')


@app.route('/login1', methods=['POST'])
def main1():
    return render_template('password.html',redirect1 =  "/login1"+request.args['path'])

What I am trying to do is asking the user for his/her email and then render a page asking for a password. However, the submit button isn't working. I am using action and method=POST submit.

Ok, I know why it didn't work.

Everytime I make an error (syntax error) OR I POST to a 404 page, I have a 404 and 500 function where it makes you login before viewing the 404/500 page. That's why it kept on redirecting to the original login page. It works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM