May-22-2020, 03:43 AM
You have skipped the second task in view function
It shall return a randomly chosen quote in h3 tag.
So to help with this view function can look like this.
Move quotes list so it's before return render_template.
In test.html use jinja to displaying quotes.
Eg.
hello_user
.It shall return a randomly chosen quote in h3 tag.
So to help with this view function can look like this.
from flask import Flask from random import choice app = Flask(__name__) @app.route("/") def hello(): return "Hello World!!! I've run my first Flask application." @app.route("/hello/<username>/") def hello_user(username): quotes = [ "Only two things are infinite, the universe and human stupidity, and I am not sure about the former.", "Give me six hours to chop down a tree and I will spend the first four sharpening the axe.", "Tell me and I forget. Teach me and I remember. Involve me and I learn.", "Listen to many, speak to a few.", "Only when the tide goes out do you discover who has been swimming naked.", ] return f"<h2>Hello {username}</h2><h3>{choice(quotes)}</h3>" if __name__ == '__main__': app.run(host='0.0.0.0', port=8000, debug=True)Hint for last view function.
Move quotes list so it's before return render_template.
In test.html use jinja to displaying quotes.
Eg.
<body> {% for list_element in name %} <ul> <li>{{ list_element }}</li> </ul> {% endfor %} </body>