Computer scienceBackendFlaskUser-specified interactions

Flask Sessions

Theory

One line fix

Report a typo

When the following code is run, it throws an error. Without knowing this error, fix the error by adding only a single line of code.

Write a program in Python 3
from flask import Flask, session

app = Flask(__name__)

languages = {
"en": "Hello, world!",
"fr": "Bonjour, le monde!",
"es": "Hola, mundo!"
}
@app.route("/")
def index():
session['lang'] = 'en'
return languages[session['lang']]
___

Create a free account to access the full topic