Skip to content Skip to sidebar Skip to footer

When My Flask Web Page Is In "get" Method, It Couldn't Connected To Any Static Files It Normally Does In "post" Method

===============SOLUTION HAD BEEN ADDED BELOW================== I have the python codes that let users edit their comments on a post page. When the users click on this button below:

Solution 1:

The filepath to the static folder is the issue. You can try this

<linkrel="stylesheet"href="{{ url_for('static/css', filename='blog_view.css') }}"><scripttype="text/javascript"src="{{ url_for('static/javascript', filename='blogview.js') }}"></script>

Solution 2:

I might be wrong, but at least worth looking at.

I read your question rather quickly. I might have more time in a few hours or tomorrow.

I assume this is your problem: '/<int:blog_validated_id>/<int:blog_info_id>' is working and everything is displayed fine

On the other hand '/<int:blog_validated_id>/<int:blog_info_id>/update' is not working

If this is the case, then the issue is that your template contains relative urls.

In the first case: "/<int:blog_validated_id>/static/css/blog_view.css"

whereas in the second case it would (because of the added /update) correspond to "/<int:blog_validated_id>/<int:blog_info_id>/static/css/blog_view.css"

Solution 3:

The problem was solved when I twitched a little bit of @Prakhar Gupta's code from above:

<linkrel="stylesheet"href="{{ url_for('static', filename='css/blog_view.css') }}"><scripttype="text/javascript"src="{{ url_for('static', filename='javascript/blogview.js') }}"></script>

Other images from the static file will have to be written in the same way I wrote for the href like above in order to not meet relative URLs issue as @gelonida said.

P.s/ I want to thanks @gelonida and @Prakhar Gupta for helping me to come up with my own solution :)

Post a Comment for "When My Flask Web Page Is In "get" Method, It Couldn't Connected To Any Static Files It Normally Does In "post" Method"