[FIXED] Why JavaScript file wont load?

Issue

In my project i use #Flask #Python #SQLite #Jinja3.1 #Chrome
Versions

I use Codespaces from CS50, I used JavaScript before in other projects but not with Jinja and was ok.

Here is an image to see status codes when I am in app.
Status Codes

Possible problem here?
browser

My app config:

app.config["TEMPLATES_AUTO_RELOAD"] = True

app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

Solution

I think your problem is in the structure of the project, all the javascript and css files have to be stored in a static folder, and html in a templates folder.

as i can see here in the logs, it’s showing that you storing the js files in a js folder but you have to replace that js folder to the static folder so it’ll look like this: project/static/js/app.js

here’s a ref: https://python-adv-web-apps.readthedocs.io/en/latest/flask3.html#:~:text=Folder%20structure%20for%20a%20Flask%20app&text=That%20folder%20contains%20two%20folders,only%20one%20asset%20file%2C%20main.

Answered By – FreazeMood

Answer Checked By – Pedro (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published