-1

In the near end of creating my server, I created a homepage and attached it to the python file, But when I tried to access the homepage from my phone, On the log it returned this:

jinja2.exceptions.TemplateNotFound: /index.html - - [25/Dec/2021 20:27:57] "GET / HTTP/1.1" 500 -

index.html exists, This is a mysterious behaviour, Advice needed.

address.py:

api = Flask(__name__)

@api.route('/')
def index():
 return render_template('/index.html')  
GitSD
  • 46
  • 2
  • 10

1 Answers1

1

index.html should be inside a directory called templates

Also you could do without the forward-slash in the argument to render_template:

  return render_template('index.html')  
v25
  • 7,096
  • 2
  • 20
  • 36
  • This solved my problem as well, thank you @v25! If I may complement the answer by saying that there is another important folder for the flask project which is the folder called **static** folder. This one should contain the assets that will be used by the templates, like javascript, css and images. – Carlos Herrera Jun 21 '23 at 01:11