OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Flask raises TemplateNotFound error even though template file exists

  • Thread starter Thread starter Srdan Ristic
  • Start date Start date
S

Srdan Ristic

Guest
I am trying to render the file home.html. The file exists in my project, but I keep getting jinja2.exceptions.TemplateNotFound: home.html when I try to render it. Why can't Flask find my template?

Code:
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def home():
    return render_template('home.html')

Code:
/myproject
    app.py
    home.html
<p>I am trying to render the file <code>home.html</code>. The file exists in my project, but I keep getting <code>jinja2.exceptions.TemplateNotFound: home.html</code> when I try to render it. Why can't Flask find my template?</p>

<pre><code>from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def home():
return render_template('home.html')
</code></pre>



<pre><code>/myproject
app.py
home.html
</code></pre>
 
Top