The Pokédex Web App exposes 9 Flask routes inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Navi-27/Proyecto-UPC/llms.txt
Use this file to discover all available pages before exploring further.
application.py. All routes serve HTML via Jinja2 templates — there is no JSON API. Routes that require authentication check for usuario_id in the Flask session and redirect to /login if no session is present.
Session data is signed with
application.secret_key. See the Configuration Reference for details on rotating this value before deploying to production.Route Overview
| Method | Path | Auth Required | Returns |
|---|---|---|---|
GET | / | No | index.html |
GET | /pokemon/<nombre> | No | detalle.html |
GET | /mi-pokedex | Yes | mi-pokedex.html |
GET | /registro | No | registro.html |
POST | /registro | No | Redirect to /login |
GET | /login | No | login.html |
POST | /login | No | Redirect to / |
GET | /logout | No | Redirect to / |
GET | /equipo | Yes | equipo.html |
GET | /equipo/agregar/<int:pokemon_id>/<nombre>/<path:imagen>/<tipos> | Yes | Redirect to /pokemon/<nombre> |
GET | /equipo/eliminar/<int:pokemon_id> | Yes | Redirect to /equipo |
Route Details
GET /
The application’s home page. Displays the full Pokédex listing with optional search and type-filter capabilities. Auth required: NoOptional. Filters the Pokémon list by name using a substring match. Applied via
Pokedex.buscar_por_nombre().Optional. Filters the Pokémon list by type (e.g.
fire, water). Applied via PokeAPI.obtener_por_tipo().index.html
Behavior:
On every request the route calls PokeAPI.validacion() to check whether the local cache_pokemon table already contains data. If the cache is empty the app fetches all 1 025 Pokémon from the PokéAPI and stores them; otherwise it reads directly from SQLite via PokeAPI.cargar_desde_db(). After loading, busqueda and tipo filters are applied in that priority order (only one filter is active at a time).
GET /pokemon/<nombre>
Displays the detail page for a single Pokémon identified by name or National Pokédex ID. Auth required: No — but view is silently logged when a user is logged in.The Pokémon’s name (e.g.
pikachu) or its National Pokédex ID as a string (e.g. 25). Passed directly to PokeAPI.obtener_pokemon().Optional. Passed through to the template unchanged — used by the breadcrumb navigation to link back to the correct type filter on the index page.
detalle.html
Behavior:
Calls PokeAPI.obtener_pokemon(nombre) to retrieve Pokémon data (from cache or live API). If usuario_id is present in the session, calls PokedexUsuario.registrar_visto() to record the view in the pokedex_usuario table — the UNIQUE constraint means duplicate views are silently ignored.
GET /mi-pokedex
Displays a list of every Pokémon the authenticated user has ever viewed. Auth required: Yes — redirects to/login if usuario_id is not in the session.
Template rendered: mi-pokedex.html
Behavior:
Calls PokedexUsuario.obtener_vistos(session['usuario_id']) and passes the result set to the template. Each row includes pokemon_id, pokemon_nombre, and fecha_visto (the timestamp of the first view).
GET /registro
Renders the registration form. Auth required: No Template rendered:registro.html
POST /registro
Processes a new user registration form submission. Auth required: NoDesired username. Must be unique —
Usuario.crear() returns False if the username already exists, which triggers an error flash message.Plain-text password. Hashed with Werkzeug’s
generate_password_hash before being stored in the usuarios table.Usuario.crear(username, password). On success, flashes a "success" message and redirects to /login. On failure (duplicate username), flashes an "Error" message and re-renders registro.html.
GET /login
Renders the login form. Auth required: No Template rendered:login.html
POST /login
Authenticates a user and establishes a session. Auth required: NoThe registered username.
The plain-text password to verify against the stored hash via
check_password_hash.Usuario.login(username, password). On success, writes usuario_id and username into the Flask session and redirects to /. On failure, flashes an "error" message and re-renders login.html.
GET /logout
Destroys the current session and returns the user to the home page. Auth required: No Template rendered: None Behavior: Callssession.clear() and issues a redirect to /. No flash message is shown.
GET /equipo
Displays the authenticated user’s current Pokémon team (up to 6 members). Auth required: Yes — redirects to/login if usuario_id is not in the session.
Template rendered: equipo.html
Behavior:
Calls Equipo.obtener_equipo(session['usuario_id']) to load the team from the equipos table and passes the rows to the template.
GET /equipo/agregar/<int:pokemon_id>/<nombre>/<path:imagen>/<tipos>
Adds a Pokémon to the authenticated user’s team. Auth required: Yes — redirects to/login if usuario_id is not in the session.
The Pokémon’s National Pokédex ID.
The Pokémon’s name. Used for the flash message and the post-add redirect back to
/pokemon/<nombre>.URL of the Pokémon’s sprite image. Uses Flask’s
<path:> converter so that forward slashes inside the URL are preserved correctly.A JSON-encoded array of type strings (e.g.
["fire","flying"]). Stored as-is in equipos.pokemon_tipos and decoded in templates with the parse_tipos filter.Equipo.agregar_pokemon(). If the team already has 6 members (Equipo.MAX_POKEMONES), the call returns (False, message) and an error flash is shown. On success, a "success" flash is shown. Either way, the response redirects to /pokemon/<nombre>.
GET /equipo/eliminar/<int:pokemon_id>
Removes a Pokémon from the authenticated user’s team by its Pokédex ID. Auth required: Yes — redirects to/login if usuario_id is not in the session.
The Pokémon’s National Pokédex ID. Used to identify the row in the
equipos table for the current user.Equipo.eliminar_pokemon(session['usuario_id'], pokemon_id). Flashes a "success" or "Error" message depending on the result, then redirects to /equipo.
Template Filter: parse_tipos
The app registers a custom Jinja2 filter named parse_tipos that converts the JSON-encoded tipos string stored in the database into a Python list for use in templates.
json.loads(). If the string is formatted as a Python literal instead of strict JSON (e.g. uses single quotes), it falls back to ast.literal_eval() for safe evaluation.