Server - Contents

Flask Security Demo

revised: 08-Sep-2023

This demo highlights the capacity to have interested persons register on the site with a valid email, confirmed with a link. Given the constraints now with the big email providers (Gmail, Yahoo, etc) this may only be attractive to an organization which provides its members with its own domain-driven mail-server. The setup can be downloaded here: secmain2-230908.tar.gz (~450Kb) It is recommended to glance throught the following files: READMe, .env, settings.py and __init__py for the notes found therein.

Steps to the Setup

With the initial virtual environment described in the Flask 3pg Site and assuming a Debian 10 environment with iRedmail functional. Upload the secmain.zip file to your home directory.

sammy@imega:$ unzip secmain2-230908.tar.gz
sammy@imega:$ cd secmain/
sammy@imega:~secmain/ $ python3 -m venv venv
sammy@imega:~secmain/ $ . venv/bin/activate  Note: the "."
(venv)sammy@imega:~secmain/$ pip install -r requirements.txt
(venv)sammy@imega:~secmain/$ python3 run.py

The app should be seen via the browser at http://(MyIP or MyDomain):5000<
Note: the first registration gives the user 'admin' rights. All registrations thereafter have only 'user' rights.

Running the App as a Service

In preparing the app to run through at webserver, one could use uwsgi and by doing the following:
a. Create in directory: /home/sammy/secmain the file: wsgi.py:

Enter the following commands:

(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 service to be render by the webserver.
Advance Flask Flask Roles Demo
Flask Blog Demo