Server - Contents

PostgreSQL Ltree into a Flask Website

new: 17-May-2025

Part B: Creating the Flask Website

As the ledger uses a Postgres database, our first task is to create a very simple Flask application with its index page. To do the following.
Step One: Create a basic Flask app (server-side explanation only), and ensure that the app successfully links with 'testdb'

sammy@imega:$ mkdir flktree
sammy@imega:$ cd flktree
sammy@imega:~/flktree$ python3 -m venv .venv
sammy@imega:~/flktree$ . .venv/bin/activate
(.venv) sammy@imega:~/flktree$ pip install flask psycopg2-binary

Step2: Create and run this app.py [text file] with the correct connection settings to test the communication between the database and the Flask app:

(.venv) sammy@imega:~/flktree$ nano app.py
(.venv) sammy@imega:~/flktree$ python3 app.py

The response in the terminal will indicate whether the connection works or there is an error.

PgLtree/Flask PgLtree/Flask-PartB
PgLtree/Flask-Deploy