++ extendido base.html -> resultados TPL
This commit is contained in:
parent
88c478081a
commit
aea2e19453
25
app.py
25
app.py
|
@ -1,10 +1,31 @@
|
||||||
from flask import Flask
|
from flask import Flask, render_template
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
return "HOLA, World!"
|
return render_template("base.html", title= " HOLA Jinja + Flask :-)")
|
||||||
|
|
||||||
|
max_score = 100
|
||||||
|
test_name = "Py Reto "
|
||||||
|
students = [
|
||||||
|
{"name": "Sandrine", "score": 100},
|
||||||
|
{"name": "Gergeley", "score": 87},
|
||||||
|
{"name": "Frieda", "score": 92},
|
||||||
|
{"name": "Fritz", "score": 40},
|
||||||
|
{"name": "Sirius", "score": 75},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/results")
|
||||||
|
def results():
|
||||||
|
context = {
|
||||||
|
"title": "Results",
|
||||||
|
"students": students,
|
||||||
|
"test_name": test_name,
|
||||||
|
"max_score": max_score,
|
||||||
|
}
|
||||||
|
return render_template("results.html", **context)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>{{ title }}</title>
|
<title>{% block title %}{{ title }}{% endblock title %}</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
{% block content %}
|
||||||
<h1>Welcome to {{ title }}!</h1>
|
<h1>Welcome to {{ title }}!</h1>
|
||||||
|
{% endblock content %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
{# templates/results.html #}
|
{# templates/results.html #}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>Results</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
{% block content %}
|
||||||
<h1>{{ test_name }} ResultadOS: </h1>
|
|
||||||
|
<h1>{{ test_name }} {{ title }}: </h1>
|
||||||
<ul>
|
<ul>
|
||||||
{% for student in students %}
|
{% for student in students %}
|
||||||
<li>
|
<li>
|
||||||
|
@ -17,5 +13,4 @@
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
{% endblock content %}
|
||||||
</html>
|
|
||||||
|
|
Loading…
Reference in New Issue