I wrote my own dynamic route to be like this:
@app.route('/')
@app.route('/<controller>')
@app.route('/<controller>/<action>')
@app.route('/<controller>/<action>/<id>') # <--- this route overrides
def main(controller = None, action = None, id = None):
The place where I marked #, that route overrides the default behavior of /static/css/filename.css because that is a valid routing. How do I serve those files with my dynamic routes?
Well, your rooting is very general and basically it grabs everything (not everything, but you understand that it matches all the strings and the structure of the URL) and matches with at least one of the rule. So if you want to preserve your rule serving static files, just have something like this
@app.route('/static/css/')and this rule should serve the view which will serve static files.But in general I don’t think that this is good way to go in general. I would say take a look to the blueprints and have modular application with the help of those. Then you can define the URL beginning for each blueprint, so you will have separation of the modules and also the routes. This general approach can cause more and more problems in the future. But it is your choice though 😉