Home > database >  Flask and Nginx: css not recognized
Flask and Nginx: css not recognized

Time:02-23

I am trying to deploy my website using Flask. Everything is working perfectly locally (localhost:5000), but when I deploy it on my distant linux ubuntu server (enter image description here

CodePudding user response:

Your static path looks fine. You have set your server to listen to port 80, which is the default port for HTTP, but maybe you have not opened it. The next step is for you to open it.

sudo ufw allow http/tcp

You mention that your server is still listening to port 5000. However, if you are done with testing, you can disallow this port from being used by Nginx.

sudo ufw delete allow 5000

Enable these new rules by running the command below:

sudo ufw enable
# Hit 'y' for 'yes' when prompted

Finally, you can now restart your Nginx server:

sudo systemctl status nginx.service 

If you navigate to your application's IP address, and append static/css/style.css, you should be able to access your CSS file. I mean http://<your IP address>/static/css/style.css

  • Related