COMPSCI 235 Starter Repository for the Games WebApp Assignments

This is a starter repository for the games webapp assignments of CompSci 235 in Semester 2, 2023.

Description

A Game Library web application that implements Python's Flask framework as well as libraries such as jinja templating. It contains features such as a game search function, browse by genre function, and a page to browse all games. Architectural design patterns and priciples including the use of a Repository and the principle of Single Responsibility. Each page also has a service layer to provide service to each request function. This application uses Flask BluePrints to maintan a seperation of concerns between application functions. Testing includes unit and end to end testing using pytest.

Installation

Installation via requirements.txt

Windows

$ cd <project directory>
$ py -3 -m venv venv
$ venv\Scripts\activate
$ pip install -r requirements.txt

MacOS

$ cd <project directory>
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

When using PyCharm, set the virtual environment using 'File or PyCharm'->'Settings' and select your project from the left menu. Select 'Project Interpreter', click on the gearwheel button and select 'Add Interpreter'. Click the 'Existing environment' radio button to select the virtual environment.

Execution

Running the application

From the project directory, and within the activated virtual environment (see venv\Scripts\activate above):

$ flask run

Testing

After you have configured pytest as the testing tool for PyCharm (File - Settings - Tools - Python Integrated Tools - Testing), you can then run tests from within PyCharm by right clicking the tests folder and selecting "Run pytest in tests".

Alternatively, from a terminal in the root folder of the project, you can also call 'python -m pytest tests' to run all the tests. PyCharm also provides a built-in terminal, which uses the configured virtual environment.

To run the tests for the database components, these are in the folder 'tests_db', so you can call 'python -m pytest tests_db' to run them from the command line.

Configuration

The project directory/.env file contains variable settings. They are set with appropriate values.

  • FLASK_APP: Entry point of the application (should always be wsgi.py).
  • FLASK_ENV: The environment in which to run the application (either development or production).
  • SECRET_KEY: Secret key used to encrypt session data.
  • TESTING: Set to False for running the application. Overridden and set to True automatically when testing the application.
  • WTF_CSRF_SECRET_KEY: Secret key used by the WTForm library.

Data sources

The data files are modified excerpts downloaded from:

https://huggingface.co/datasets/FronkonGames/steam-games-dataset