I am working on my pet-project which is supposed to take user's data from web page and show the result (calculated on python). I just do not know how to connect my python code with html+css+js page.
I have read a lot of articles, watched videos on YouTube. As a result, I understood that the main technologies I'm going to use are cgi, flask and py-script. So, I've added all of them to my project as I'm a beginner.
I am adding my repo on github
https://github.com/5724gnvasya/Decision-support-system ,
where are all files, which you can open on your VSCode, for example.
When I'm writing on the terminal
cd src
python app.py
all needed calculations are working correctly (but css file is not - Failed to load resource: the server responded with a status of 404 (NOT FOUND)).
When I click Go Live in the lower right corner in VSCode, all html, css, js are working, but python calculations are not - Failed to load resource: the server responded with a status of 405 (Method Not Allowed).
I really do not know how to fix that. How to make correct calculations displayed on my beautiful page (html+css+js)? Please help me. I will be very grateful!
The problem is with where you're storing your static files (images, JS and CSS).
Flask requires that you store these static files in the static
directory, as explained in the documentation. That way, you'll be able to access your CSS.
The first thing you need to do is change your project structure.
It currently looks like this:
└── src/
└── css/
└── icons/
└── img/
└── js/
└── templates/
└── app.py
You will need to change it to:
└── src/
└── static/
└── css/
└── icons/
└── img/
└── js/
└── templates/
└── app.py
Once you've done that, change how you're calling your static files to something like:
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style_main_page.css') }}">