Theme
Primary Color
Lesson 136

Flask – Jinja Template

ال Code الموجود في الدرس

# ------------------------------------
# -- Flask => Jinja Template Engine --
# ------------------------------------

from flask import Flask, render_template

skills_app = Flask(__name__)

@skills_app.route("/")
def homepage():
  return render_template("homepage.html", title="Homepage")

@skills_app.route("/about")
def about():
  return render_template("about.html", title="About Us")

if __name__ == "__main__":
  skills_app.run(debug=True, port=9000)
base.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>{{ title }}</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}" />
    <link rel="stylesheet" href="{{ url_for('static', filename='css/master.css') }}" />
  </head>
  <body>
    {% block body %}
    {% endblock %}
  </body>
</html>