Theme
Primary Color
Lesson 137

Flask – Advanced CSS Task Using Jinja

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

# --------------------------------------------
# -- Flask => Advanced Css Task Using Jinja --
# --------------------------------------------

from flask import Flask, render_template

skills_app = Flask(__name__)

@skills_app.route("/")
def homepage():
  return render_template("homepage.html",
                          title="Homepage",
                          custom_css="home")
@skills_app.route("/add")
def add():
  return render_template("add.html",
                          title="Add Skill",
                          custom_css="add")

@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') }}" />
    {% if custom_css %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/' + custom_css + '.css') }}" />
    {% endif %}
  </head>
  <body>
    {% block body %}
    {% endblock %}
  </body>
</html>