Server - Contents

PostgreSQL Ltree into a Flask Website

new: 17-May-2025

Part C: A Basic Ltree/Flask Application

There three sections: app.py and two html files; index.html and layout.html (to provide styling) in the templates folder.
Step One: Create the app.py

sammy@imega:~/flktree$ nano app.py

In the first part of app.py, we set the modules and the helper function.

For the second part of app.py, it comprises of all the routes for a full CRUD ability plus a route to capture exceptions arising from faulty search queries (debug should be set to 'False').

A complete rendering of app.py as a text file: flktree-app.py.txt

sammy@imega:~/flktree$ mkdir templates
sammy@imega:~/flktree$ nano templates/layout.html -see contents below
sammy@imega:~/flktree$ nano templates/index.html -see contents below

Now for the layout.html: flktree-layout.html.txt

And for the layout.html:flktree-index.html.txt

With these files in place, start the application (if no errors, set debug to False)

sammy@imega:~/flktree$ python3 app.py
PgLtree/Flask PgLtree/Flask-PartB
PgLtree/Flask-Deploy