Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Flask no reconoce el controlador cuando se usa `url_for()` en formato HTML

Al intentar implementar un formulario básico, aparece el siguiente mensaje de error: werkzeug.routing.BuildError: Could not build url for endpoint 'finder.search'. Did you mean 'finder.static' instead? , la página index.html ni siquiera se carga debido a este error.

Directorio

 Steam SteamFinder static style.css templates index.html result.html __init__.py finder.py venv

iniciar .py

 from flask import Flask from flask.templating import render_template def create_app(): # create and configure the app app = Flask(__name__) from . import finder app.register_blueprint(finder.bp) @app.route("/") def home(): return render_template("index.html") return app

buscador.py

 from flask import Blueprint, request from flask.templating import render_template bp = Blueprint("finder", __name__, template_folder="templates", static_folder="static") bp.route("/search", methods=["POST"]) def search(): query = request.form["query"] print(query) return render_template("result.html")

índice.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="../static/style.css"/> <title>Home</title> </head> <body> <form action="{{ url_for('finder.search') }}" method="post"> <label for="query">Query:</label><br> <input type="text" id="query" name="query"><br> <input type="submit"> </form> </body> </html>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No puede usar url_for directamente en la plantilla, Jinja no puede procesarlo. Debe pasarlo como una variable a la función render_template y usar ese nombre de variable en el bloque jinja.

Ejemplo:

 return render_template("index.html", form_action_url=url_for('finder.search'))

y la acción del formulario será:

 <form action="{{ form_action_url }}" method="post"> <label for="query">Query:</label><br> <input type="text" id="query" name="query"><br> <input type="submit"> </form>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!