0

I am trying to link to my own html page that I have created in CS50 IDE. The html code is below. I have included 8 variations on trying to find the file. All return error 404.

I have the file: "pct.html" saved under the "templates" sub-directory and in the root project directory.

The last link is to an external website and works fine.

Any help to allow the href to work - either as a straight link or within the button - is appreciated. (I was using the button because I preferred that look and feel of the page with the buttons.)

There is more html in this file which is patterned after the layout file from Pset8-Finance; however, the clicking on the link will not open the pct.html file.

        <a href="pct.html">Income needed in retirement</a>
        <a href="pct.html" class="button">Income needed in retirement</a>
        <br>
        <a href="/pct.html">Income needed in retirement</a>
        <a href="/pct.html" class="button">Income needed in retirement</a>
        <br>
        <a href="templates/pct.html">Income needed in retirement</a>
        <a href="templates/pct.html" class="button">Income needed in retirement</a>
        <br>
        <a href="/templates/pct.html">Income needed in retirement</a>
        <a href="/templates/pct.html" class="button">Income needed in retirement</a>
        <br>
        <a href="https://www.fidelity.com/viewpoints/retirement/spending-in-retirement" class="button">You need 50-80% of your income in retirement</a>
</form>

{% endblock %}

  • What do you mean "conversion to html"? If flask is your server, then every endpoint must be a route in applcation.py. – DinoCoderSaurus Aug 25 at 11:20
  • I edited the question to clarify the meaning of conversion. I can link to open a new web page without going through application.py (the last link to fidelity.com works). What I want to do is open the html to generate a web page of my own making that is stored in CS50 IDE. Does your comment mean that I can only do that by sending a response to application.py and having application.py then render the html file that I want shown? i.e. there is no possibility to directly link from one html file to another without a going through application.py? – Kelvin Winspinger Aug 26 at 1:41
0

All static files, simply put files that does not encompass Jinja templates or any other template literals , should be placed under the folder static which then will be available via the default URL path /static/<file reference>.

In contrast, any file that utilises the Jinja or any other template library should be moved into the designated template folder and should have a corresponding route entry.

Moving the pct.html to folder static under root project directory should make the file accessible via /static/pct.html by default. Subsequently, the markup should be altered to something similar to below.

<a href="{{ url_for('static', filename='pct.html') }}">...</a>
<a href="/static/pct.html">...</a>

The Flask tutorial on Static Files should serve extensively useful for further clarifications.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .