I’m deploying a python3 flask application in aws elasitc beanstalk (Amazon Linux 2 platform). The folder structure is as follows:
|-app/ |-templates/ |-static/ | |-css/ | |-js/ |-app.py
In the template files, importing of static resources are defiled as: i.e. JS file:
In the EB configurations, I’ve defined the static resources as below
But the problem is, these resources are not loading and giving 404.
https://example.com/static/js/jquery.js cannot be loaded. But if I try
https://example.com/js/jquery.js, it works.
Have I done the configurations wrong??
Based on the comments.
The issue was due to overwriting
/static path. In python EB environments,
/static path is used by default to server the static content:
By default, the proxy server in a Python environment serves any files in a folder named static at the /static path. For example, if your application source contains a file named logo.png in a folder named static, the proxy server serves it to users at subdomain.elasticbeanstalk.com/static/logo.png. You can configure additional mappings as explained in this section.
The solution was to use the default settings and remove the overwrite.