Python and Flask blog part 5

 

Now we are gonna create the templates folder where our html file will go. We use the views to render our html content pages. With render_template we can make it in a better way, using different html files instead of including the html code into the routes.py file.

This is the new routes.py file

from flask import render_template
from blog import app

@app.route("/")
def homepage():
    return render_template("homepage.html")

Il file homepage.html con qualche tag html

<html>

<style>
body {
color: coral;
background-color: black;
}
</style>

<body>
<h1>Welcome to our Homepage</h1>
<p>Hello World</p>
</body>
</html>

 

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.