Server - Contents

Flask Other Demos

revised: 11-Apr-2025

1. Login App with both Public and Private Pages

This a suitable app for an office website, very customizable with Bootstrap5 styling. As usual, see the README file for further details.

With the initial virtual environment described in the Flask 3pg Site and assuming a Ubuntu server environment with iRedmail functional. Upload the flklogin.zip (55Kb) file to your home directory.

sammy@imega:$ unzip flklogin
sammy@imega:$ cd flklogin/
sammy@imega:~flklogin/ $ python3 -m venv .venv
sammy@imega:~flklogin/ $ . .venv/bin/activate  Note: the starting "."
(venv)sammy@imega:~flklogin/$ pip install -r requirements.txt
(venv)sammy@imega:~flklogin/$ export FLASK_APP=src
(venv)sammy@imega:~flklogin/$ python3 manage.py run

The app should be seen via the browser at http://(MyIP or MyDomain):5000
Note: The admin user: admin@abc.com pwd: a1234s

Running the App as a Service

In preparing the app to run through at webserver, one is recommend to use uwsgi then setup as a service. Take the following steps and by creating the file: wsgi.py

Enter the following commands:

(venv)sammy@imega:$ pip install uwsgi
(venv)sammy@imega:$ nano wsgi.py ##copy-paste above instructions.
(venv)sammy@imega:$ uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app

Note: The above confirms if the settings within wsgi.py are correct. The app should be seen via the browser at http://(MyIP or MyDomain):5000

Using a similar setup described in Step#3 (PartB) in Flask 3pg Site, one can establish the systemd service to be render by the webserver.

Two Other Login Examples

A Login App using JWT sessions and registering Users within code

A very simple but informative app wherein users are registered within the main programme in an array called USERS (no database required). A straight-forward terminal command is executed to provide encrypted passwords. More details are found in the README file and the comprehensive application is available here: jwt.zip (6Kb)

2. A Login App using Flask-Login and Flask-Sqlalchemy

A good clear but simple example on how to setup a register/login feature in Flask tied to a database (eg. Sqlite3). The application can be found here: login.zip (8Kb)

Advance Flask Flask Roles Demo
Flask Blog Demo