++ 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.route("/")
|
||||
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__":
|
||||
app.run(debug=True)
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ title }}</title>
|
||||
<title>{% block title %}{{ title }}{% endblock title %}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Welcome to {{ title }}!</h1>
|
||||
|
||||
{% block content %}
|
||||
<h1>Welcome to {{ title }}!</h1>
|
||||
{% endblock content %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
{# templates/results.html #}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Results</title>
|
||||
</head>
|
||||
{% extends "base.html" %}
|
||||
|
||||
<body>
|
||||
<h1>{{ test_name }} ResultadOS: </h1>
|
||||
{% block content %}
|
||||
|
||||
<h1>{{ test_name }} {{ title }}: </h1>
|
||||
<ul>
|
||||
{% for student in students %}
|
||||
<li>
|
||||
|
@ -17,5 +13,4 @@
|
|||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock content %}
|
||||
|
|
Loading…
Reference in New Issue