-1

when im trying to run the main.py i got TemplateNotFound: index.html

project file structure

app

templates : base.html, index.html

static

views.py

## viwes.py 

from flask import render_template, request
from flask import redirect, url_for 



def base():
    return render_template('base.html')

def index():
    return render_template('index.html')

def faceapp():
    return render_template('faceapp.html')

##main.py 


from flask import Flask
from app import views

app = Flask(__name__)

#### URL
app.add_url_rule('/base', 'base',views.base)
app.add_url_rule('/','index', views.index)
app.add_url_rule('/faceapp','faceapp', views.faceapp)


### RUN 
if __name__ == "__main__":
    app.run(debug=True)```
Hossam Fid
  • 15
  • 4
  • Not clear from your diagram. Is the structure `./templates` or `./app/templates`? I wouldn't expect the latter to work. – Dave W. Smith Jun 01 '21 at 02:19

1 Answers1

0
app = Flask(__name__, template_folder='path/to/templates/dir')

You can also explicitly define the path to the template directory as above.

You can also refer Flask Template for more details.

Akshay Jain
  • 790
  • 1
  • 7
  • 21