.. _flask: .. relock documentation service file, created by sphinx-quickstart on Wed May 14 18:37:20 2025. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Run demo app from source ------------------------ This section guides through setting up the Flask demo application from source. It covers setting up the Relock service, installing dependencies, configuring services, and running the application. .. include:: relock_setup.rst Set up demo app storage ~~~~~~~~~~~~~~~~~~~~~~~ The demo application requires persistent storage for storing user-related data (e.g., email, passwords, profile information). It is designed to use a MySQL database. To simplify setup and ensure a clean environment, we recommend starting with a fresh MySQL container. For enhanced security, Relock’s cryptographic keys are stored separately in a dedicated in-memory database. .. code-block:: bash $ docker run --name mysql \ --restart always \ -v ./data/mysql:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=#SupperSecret123 \ -e MYSQL_USER=admin \ -e MYSQL_PASSWORD=#SupperHidden123 \ -e MYSQL_DATABASE=demo \ -d -it mysql \ --character-set-server=utf8mb4 .. _flask_github: Clone demo repository ~~~~~~~~~~~~~~~~~~~~~ Obtain the source code for the Flask demo application from its public GitHub repository. .. code-block:: bash https://github.com/relockid/flask Start Python virtual enviroment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create and activate a Python virtual environment to manage dependencies for the Flask application. This isolates project packages from the base Python installation. .. code-block:: bash python3 -m venv venv source venv/bin/activate Install app dependencies ~~~~~~~~~~~~~~~~~~~~~~~~ Install the necessary Python packages for the Flask demo application based on its ``requirements.txt`` file. In some environments, ``pip3`` may be required instead of ``pip``. .. code-block:: bash python3 -m pip install -r requirements.txt Install Relock Python SDK ~~~~~~~~~~~~~~~~~~~~~~~~~ This command installs the latest version of the Relock SDK for Python from the Python Package Index (PyPI). .. code-block:: bash python3 -m pip install relock To explore or contribute to the Relock SDK source code, it can be downloaded directly from GitHub. The official Relock SDK repository can be cloned by running: .. code-block:: bash git clone https://github.com/relockid/python Configure environment variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Create an ``.env`` file in the Flask application's root directory. This file will contain the configuration settings, allowing the Flask app (running on the host) to connect to the Dockerized services: .. code-block:: bash DB_USER=admin DB_PASS=#SupperHidden123 DB_HOST=172.17.0.3 DB_PORT=3306 DB_NAME=demo REDIS_HOST=172.17.0.2 REDIS_PORT=6379 REDIS_DB=0 RELOCK_SERVICE_HOST=172.17.0.4 RELOCK_SERVICE_PORT=8111 RELOCK_SERVICE_POOL=8 RELOCK_SERVICE_PING=True RELOCK_SERVICE_TIMEOUT=60 RELOCK_BLUEPRINT=relock MAIL_SERVER= MAIL_PORT=587 MAIL_USE_SSL=False MAIL_USE_TLS=True MAIL_DEBUG=1 MAIL_USERNAME= MAIL_PASSWORD= MAIL_REPORT=False MAIL_ERRORS=None MAIL_DEFAULT_SENDER='demo page ' NAME=Relock-Demo HOST=relock.demo MAIN=main IP=0.0.0.0 Run demo app ~~~~~~~~~~~~ Once the necessary setup for Relock is complete, including SSL certificate and local domain configuration, the demo application server can be run from the source code. .. code-block:: bash $ python3 main.py demo To access the demo, open a web browser and navigate to ``https://relock.demo``. Since the SSL certificate was trusted in previous steps, the app should now be accessible over HTTPS without security warnings.