I ma trying to run a flask app python app.py
in a venv, but it's not running for some reason, there is no error, but nothing is happening, in addition to that, when I run index.html alone the jinja doesn't work and I get
{% extends "layout.html" %} {% block title %}search{% endblock title %} {% block body %}
(a text input and a button)
{% endblock body %}
so maybe there is problem with my layout.html or jinja, this is my layout.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock title %}</title>
</head>
<body>
<header>
<a id="searchlink" href="index.html" class="active">Text search</a>
<a id="imagelink" href="image.html">Images search</a>
<a id="advansedlink" href="advansed.html">Advansed search</a>
</header>
{% block body %}{% endblock body %}
</body>
</html>
and this is my index.html
{% extends "layout.html" %}
{% block title %}search{% endblock title %}
{% block body %}
<form action="https://www.google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
{% endblock body %}
and the app.py file
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
You need to put all html
file related to folder called templates
this is standard way to render html page in flask.
Put structure like this
and run your code with this command flask run
or python app.py
You should see your code will running like this.