Server - Contents

SQL-Ledger linked to Flask Website

new: 17-Apr-2025

Small businesses that are using SQL-Ledger may well find it useful to link some of the 'Parts' registered in the ledger to feature as items for sale on an easy to maintain Flask website.

Prerequisites:
1. To have an Ubuntu/Debian server up and running - as per this presentation: Virtual Server
2. To have the SQL-Ledger up and running with a 'dataset' called 'testdb' and the Postgres owner 'sql-ledger' set with a password see: SQL-Ledger Setup
3. To have been familiar with the set-up of a 3-Page Flask Website; its PC host reflected together on the server - see 3-Page Flask Website

Part A: Creating the Links

As the ledger uses a Postgres database, our task is first to create a very simple Flask app 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 myproject
sammy@imega:$ cd myproject
sammy@imega:~/myproject$ python3 -m venv .venv
sammy@imega:~/myproject$ . .venv/bin/activate
(.venv) sammy@imega:~/myproject$ pip install flask psycopg2-binary

Step2: Create and run app.py [text file]

(.venv) sammy@imega:~/myproject$ nano app.py
(.venv) sammy@imega:~/myproject$ python3 app.py
SQL-Ledger/Flask SQL-Ledger/Flask-PartB
SQL-Ledger/Flask-Deploy