/dynamic-website

Flask-based dynamic website implemented for the CMT120 course at Cardiff University.

Primary LanguagePython

CMT120 Coursework 2 - Dynamic Website

Username: c22076452

Link to website: http://c22076452-cmt120-cw2-prod-c22076452-cmt120-cw2.apps.openshift.cs.cf.ac.uk/


Demo Video

Website Video Demo


References - Source Code:

Images used throughout the site are appropriately referenced in the form of in-line comments.


Instructions (Local Deployment - Empty Site)

You may opt to use a virtual environment as follows:

On Windows (NT)

python3 -m venv venv
.\venv\Scripts\activate

On UNIX-based systems (POSIX)

python -m venv venv
source venv/bin/activate

Install the required packages using pip.

pip install -r requirements.txt

Run the following command to create the database:

python db_creation.py

Then press Enter to confirm creation. You will be prompted to enter an Admin password. This password will be used to set up the Admin account.

Then, run the Flask application:

flask run

Alternatively, you can run the application using the following command:

python wsgi.py

Instructions (Remote Deployment)

Prerequisites

Inject the following environment variables into the deployment:

  • ENV_TYPE - should either be PROD or STAGING
  • MYSQL_ADDRESS - MySQL Database Address
  • MYSQL_DB_NAME - MySQL Database Name
  • MYSQL_USER - MySQL Database Address
  • MYSQL_PASSWORD - MySQL Database Password

The database must be in MySQL, other databases can work by modifying the dialect and driver parts of the URI in cfg.py. Just ensure that the environment variables are set up properly and that the database URI is correctly formatted using the logs.

Initial Setup

On the shell of the deployment container, run the following commands:

python db_creation.py

You should see the address and name of the target database, ensure that they are the correct parameters. Then press Enter to confirm creation. You will be prompted to enter an Admin password. This password will be used to set up the Admin account.

You may now serve the application through a pod restart.