Reputation: 525
I'm making complex application using Flask and Blueprints. It work great when I run it and ask for module index function with "/" path. However, as soon as I add another page/function (for example /verificator/dhashboard in the example below or any other), it routes such link to 404.
Here is the code for one of my "backoffice" modules called "verificator":
from flask import Blueprint, render_template
from backoffice import login_required
from backoffice import app
# Define Blueprint
mod_verificator = Blueprint("verificator", __name__, url_prefix='/verificator/', template_folder="templates")
@mod_verificator.route('/', methods=['GET', 'POST'])
@login_required
def verificator():
return render_template("verificator.html")
@mod_verificator.route('/dashboard/', methods=['GET', 'POST'])
def dashboard():
return render_template("dashboard.html")
# Register blueprint(s)
app.register_blueprint(mod_verificator)
and Log output:
2017-11-25 22:55:14,614 : DEBUG : verificator: 12: <module> : _ name _: backoffice.mod_verificator.verificator
2017-11-25 22:55:14,614 : DEBUG : verificator: 13: <module> : mod_name : verificator
2017-11-25 22:57:17,459 : INFO : _internal: 87: _log : 127.0.0.1 - - [25/Nov/2017 22:57:17] "GET /verificator/ HTTP/1.1" 200 -
2017-11-25 22:57:40,902 : INFO : _internal: 87: _log : 127.0.0.1 - - [25/Nov/2017 22:57:40] "GET /verificator/dashboard/ HTTP/1.1" 404 -
so, "verificator" module renders template (and 200 http code) and verificator/dashboard fails miserable with 404.
I'm totally lost and ask for your help!
Upvotes: 0
Views: 200
Reputation: 6556
Based on your url_prefix
setting, you set the trailing slash for /verificator/
, if you want to get dashboard, you need this url in your browser:
http://127.0.0.1:5000/verificator//dashboard/
However, you'd better remove the the trailing slash to be /verificator
, so that you can access through:
http://127.0.0.1:5000/verificator/dashboard/
Upvotes: 2