October 23, 2024
Chicago 12, Melborne City, USA
HTML

jinja2.exceptions.TemplateNotFound: base.html


I’m a beginner and trying to apply some of what I’ve learn using Flask and Html to make a website as a personal project but I’m getting this error(jinja2.exceptions.TemplateNotFound: base.html) and I’ve tried everything there is in Internet. Could you help me please?

Code routes:

from flask import Blueprint, render_template

main_bp = Blueprint("main", __name__)

@main_bp.route('/')
def home():
    return '12345'

@main_bp.route('/example')
def cama():
    return render_template('base.html')

code init:

from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from jecco.routes import main_bp



app = Flask(__name__, template_folder= "..templates/")

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)
from jecco.models import *


app.register_blueprint(main_bp)

html file:

<!doctype html>
<html lang="es">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <title>MyProject</title>
  </head>
  <body>
    <header style="background-color: cornflowerblue;">
      <h1>Welcome</h1>
      <a href="{{ url_for('home')}}">Inicio</a>
      <a href="">Catalogo</a>
      <a href="">Rendimiento</a>
      <hr>

     </header>
     <h1>Hello, world!</h1>

   </body>
 </html>

files tree:

│ run.py

├───instance
│ site.db

├───jecco
│ models.py
│ routes.pyyour text
init.py

└───templates
base.html

I’ve tried without specifying the templates path and changing the folders, I’ve deleted the cache, and deleted the base.html and making it again and nothing works.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video