Skip to content

This program demonstrates a simple user registration and login system using flask framework without ORM

License

Notifications You must be signed in to change notification settings

maxwelbarno/user-auth-system

Repository files navigation

Build and Deploy Coverage Status Quality Gate Status Maintainability

Setup

To run the project locally

  1. Clone this repository

  2. From the terminal, navigate to the root directory of the cloned project

  3. Create virtual environment

  4. Install dependencies in the requirements.txt file

    pip install -r requirements.txt

Run application

  1. Create .env file in the root directory and assign the following environment variables

    FLASK_DEBUG=1
    FLASK_ENV=
    MYSQL_PASSWORD=
    MYSQL_USER=
    MYSQL_DB=
    MYSQL_HOST=
    SECRET_KEY=
    

a. Using inbuilt Werkzeug Server

  1. From the terminal in the project root directory, run the following command

    flask --app run.py run

b. Using Gunicorn Server

  1. Create gunicorn configuration file gunicorn.conf.py in the root directory and add the following environment variables

    import os
    
    os.environ["FLASK_ENV"] =
    os.environ["MYSQL_USER"] =
    os.environ["MYSQL_PASSWORD"] =
    os.environ["MYSQL_DB"] =
    os.environ["SECRET_KEY"] =
    
    bind = "0.0.0.0:5000"
    wsgi_app = "run:app"
    
  2. From the terminal in the project root directory, run the following command

    gunicorn --config gunicorn.conf.py

Dockerize application

  1. Open terminal in the root directory

  2. Create production.env file in the root directory and assign the following environment variables

    FLASK_DEBUG=1
    FLASK_ENV=
    MYSQL_PASSWORD=
    MYSQL_USER=
    MYSQL_DB=
    MYSQL_HOST=
    SECRET_KEY=
    
  3. Setup docker

    docker login

  4. Navigate to the application's root directory

  5. Build docker image

    docker build --tag user-auth-system .

  6. Start docker application

    docker compose up --detach --build

    NB: The above command builds, recreates, starts and attaches to all containers defined in docker-compose.yaml file. It fires the multi-container application up and running.

  7. To stop docker application, run the following command from terminal

    docker compose down

About

This program demonstrates a simple user registration and login system using flask framework without ORM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published