vendredi 8 octobre 2021

Why Pythonanywhere show an error when I use an if statement?

I am making a text based adventure game using python. I am using flask on PythonAnywhere.

The if statement under the base function returns a syntax error. Can someone tell me why this happens?

This has happened before with if statements under functions.

PythonAnywhere is not very descriptive when it comes to their syntax errors.

from flask import Flask, render_template, request, redirect

app = Flask(__name__)
input_list = ["This is some text", "This is some more text", "This is another line"]

@app.route('/')
def base():
    if len(input_list) > 3;
        input_list = ["This is some text", "This is some more text", "This is another line"]
    return render_template('base.html', input_list=input_list)

@app.route('/', methods=['POST'])
def list_update():
    text = request.form['text']
    input_list.append(text)
    return redirect('http://davellani.pythonanywhere.com/?text=1')

if __name__ == '__main__':
    app.run()

This is the resulting website http://davellani.pythonanywhere.com/

Aucun commentaire:

Enregistrer un commentaire