#!/usr/bin/python3
"""Flask backend for handling requests"""
from flask import Flask, render_template
from models import storage
from models.state import State

app = Flask(__name__)
# app.jinja_env.trim_blocks = True
# app.jinja_env.lstrip_blocks = True


@app.route('/states_list', strict_slashes=False)
def states_list():
    """display a HTML page with a list of states

    Returns:
        str: rendered html

    """
    return render_template("7-states_list.html", states=storage.all(State))


@app.teardown_appcontext
def teardown(exc):
    """called after each request

    Args:
        exc (Exception): unknown, seems necessary based on docu

    """
    storage.close()


if __name__ == "__main__":
    app.run(host="0.0.0.0")
