-1

I have a Flask application, where I just created a new HTML file, which I want to link to, but it says URL not found. I have tried both using the url_for and just linking directly with the path, but nothing works.

I'm not sure if it's a problem with sublime or Flask. I can easily link other HTML I have created in the past, but the new HTML just won't do it.

here is the picture of the files I have in my templates folder

Do I have no idea why this is happening?

I have made to different HTML pages in sublime and saved them as HTML pages. Whenever I use the open in browser option it works fine, but not when I run it in the application.

I tried to use the UNIX command curl 127.0.0.1:5000/test to test the specific URL and got the error curl: (7) Failed to connect to 127.0.0.1 port 5000: Connection refused

davidism
  • 121,510
  • 29
  • 395
  • 339
Kristoffer Tølbøll
  • 3,157
  • 5
  • 34
  • 69

1 Answers1

0

For flask. to have a template you need a template folder. In that folder you add your html file. in your main directory where your server file is have a folder called template. Add all your html files in that folder. to receive that html file on your server have.

@app.route("/test")
def test():
    return render_template("test.html")

the render_template method is a build in template in flask that looks for the template folder as its root directory and finds the file listed as an argument in that folder.