I want to implement a simple site layout:
/
should display home.html
/one
, /two
, /three
Should display one.html
, two.html
, three.html
respectively
So far I have come up with the following code:
main_page = Blueprint('main', __name__)
category_page = Blueprint('category', __name__)
@main_page.route("/")
def home():
return render_template('home.html')
@category_page.route('/<category>')
def show(category):
return render_template('{}.html'.format(category))
app = Flask(__name__)
app.register_blueprint(main_page, url_prefix='/')
app.register_blueprint(category_page, url_prefix='/categories')
That way I can route categories
to /categories/<category>
. How can I direct them only to /<category>
, while preserving the home.html
related /
? Appreciate your help
I tried two approaches:
Setting url_prefix='/'
for both drawings => the second does not work.
Instead, main_page
use only app.route('/')
for rendering home.html
. This also does not work when mixing with the category_page
plan.
source
share