Workflow and templates follow for a small, routed, multi-page flask app - for MacOS / Linux based systems only.

First of all we need to set up the folder structure ready to host the project, setup and activate the python virtual environment, and install flask.

mkdir flask_demo
cd flask_demo
python -m venv venv
source venv/bin/activate
pip install flask
-m pip install --upgrade pip
pip list

Package            		Version
click				8.1.3
Flask 				2.2.3
importlib-metadata  		6.0.0
itsdangerous             	2.1.2
Jinja2                         	3.1.2
MarkupSafe              	2.1.2
pip                            	23.0.1
setuptools               	49.2.1
Werkzeug                  	2.2.3
zipp                           	3.15.0

Next we create the main program file in the root folder - in this case I have called it

touch is a very simple file that imports app from the program folder.

from program import app

Next we create the program subfolder, and create two files within it. __ init and

mkdir program
cd program

__ init

__ init is the main application. Here we import Flask, assigns itself within Flask to the app variable we called into the main program, and also imports

from flask import Flask

app = Flask(__name__)

from program import routes starts off by identifying the routes or addresses within the application. also imports the render_template module und uses it to render any html templates that have been stipulated against each route, rather than stipulating output directly here.

from program import app
from flask import render_template


def index():
	return render_template('index.html')

def about():
	return render_template('about.html')

def work():
	return render_template('occupancy_calculator.html')

Finally we create a templates subdirectory within the program folder, and we create our template files within it.

mkdir templates
cd templates
touch base.html
touch index.html


We create base.html - we sets out the main html page structure that the app will use. Note the jinja templating inside the curly brackets, calling in the content of linked templates.

      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!-- load MUI -->
      <link href="//" rel="stylesheet" type="text/css" />
      <script src="//"></script>
        <div class="mui-panel">Menu Bar - 
            <button class="mui-btn mui-btn--raised"><a href="/index">Home</a></button>
            <button class="mui-btn mui-btn--raised"><a href="/100Days">100 Days</a></button>
        {% block content %}{% endblock %}


Then we create all of the other page templates - note the jinja templating again, first declaring the extension of the base template, declaring the block content, and then defining the content.

{% extends "base.html" %}

{% block content%}
		<p>This is the text we've included in our HTML files</p>

{% endblock%}

Finally, we return to the route folder, and run flask.

cd ..
cd ..
flask run

One extra thing that we can do is to install the python-dotenv, defining the app within the environment to speed up each launch.

pip install python-dotenv
touch .flaskenv
env | grep FLASK_APP
flask run