-1

I've encountered this weird issue that if I try to modify @app.route(), my template for some reason stops loading its resources, like CSS and JS files.

With a route like this:

@app.route("/users/<user_id>")

it seems to be working fine and all is displayed correctly. If I modify it to

@app.route("/users/edit/<user_id>")

or

@app.route("/users/<user_id>/edit")

then the template itself works and loads correctly with the information about the specified user, but completely without resources, just HTML code. And in Chrome's Developers Tools there are errors for not finding the resource files.

I'm just working on a template project, learning things step by step, and while exploring the app routing and getting some variables through its parameters encountered this unexplained behaviour and trying to understand why it's happening this way.

  • Is the same template being rendered in both cases? – John Gordon Jun 11 '19 at 14:19
  • Could you look up which URI:s it's hitting when it's working/not working in your browsers dev tools? Is it maybe using the wrong base for your URL? – Hultner Jun 11 '19 at 14:22
  • I think I've found the issue. In case of `@app.route("users/edit/...")` the URL for the resources that template is looking is `http://127.0.0.1:5000/users/static/...` instead of just `http://127.0.0.1:5000/static/...` Question is why it changes if physically the files are still in the same directories? – Yuri Lavrik Jun 11 '19 at 14:36

1 Answers1

0

All right, thanks for the hints that helped me to track the issue, posting here an answer in case someone will come across this question. I just made a mistake in HTML code when was linking the resource files in my "layout.html". Here's the code that works now:

<link href="/static/css/styles.css" rel="stylesheet">

With a / in front.