Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jinja2 template not found and internal server error

Python code:

from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")

def hello():

    return render_template('testing.html')

if __name__ == "__main__":
    app.run()

Html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>My name is pk</h1>
</body>
</html>

Also how to enable jinja2 in pycharm community version. I am directly creating html file and .py file in the same project

like image 449
pk786 Avatar asked Mar 10 '23 18:03

pk786


1 Answers

flask file structure

|-app
|--templates // where your html files must be in
|--static // where your js and css files must be in
|--.py files
|--other packages

Also jinja is enabled in your system, if you have already downloaded flask package.

like image 186
umit.kas Avatar answered Mar 12 '23 06:03

umit.kas