This repository contains Vet App website and software
- Initial Setup
It is recommended to install XAMMP. It includes a local Apache web server, MariaDB (MySQL), and phpMyAdmin for database management.
After installation, open the XAMMP control panel and start the Apache and MySQL services if they are not already running. You should be able to access phpMyAdmin at http://localhost/phpmyadmin
If first time using git
-
When first starting new project make sure to initilize git with command
git init
Else
- Clone this repository with
git clone https://github.com/jgustavoj/vet_app.git
At this moment were updating documentation for node.js installation and settings. Skip this step for now as is inclined to speed up production package and assist in development process. But not necessary.
- At the time of development this project was created with python 3.9.2 (recommended), anything higher will cause modifications not explained in this docuemenation.
- (Recommended) Create a new virtual environment for this project, and activate it: Follow this steps:
-
Create environment
venv
python -m venv venv
-
Activate environment; this will change depending on your system
If you are using git bash for windows you need to initilize the command
source venv/Scripts/activate
if you are using CMD then the activate.bat should work fine.
.bat files can't run in git bash
- Install Flask and other Python dependencies by running
pip install -r requirements.txt
from the repository root directory.
Flask config files are located in the config/
directory. By default, default.cfg
is always loaded, then values from it may be overwritten by additional context-specific config files.
Most of the values in default.cfg
are expected to be pulled in from OS environment variables (so API keys and other secrets are not committed to the repository). For local development, you will need a config/local.cfg
file that contains these secrets, and any other values you need to change to get the app running locally (such as the database URI). This repo contains an example local.cfg
in config/local_example.cfg
as a reference for how these files work.
Create a database for the project Make a note of what you name the database.
You may need to adjust values in local.cfg
to match the MySQL settings on your machine. (XAMMP does not set MySQL up consistently, especially across different operating systems, so this is hard to predict). Once you figure out your credentials and which port the MySQL service is running on, update SQLALCHEMY_DATABASE_URI
in local.cfg
# Format
# SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{username}:{password}@localhost:{port}/{dbname}?charset=utf8mb4'
# Actual Example
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@localhost:3306/tfc?charset=utf8mb4'
Start the local server with python flaskapp.py
If things are set up properly, you should see within the output:
* Debug mode: on
[...]
Loading config from config/default.cfg
Extending config from config/local.cfg
The application should now be available at http://localhost:3000
(or a different PORT specified in local.cfg
).
Once the server is running, go to http://localhost:3000/setup/init-db
to create database tables for this project in the database specified by the SQLALCHEMY_DATABASE_URI
in config/local.cfg
. You should see "SUCCESS" in the browser window.
Pytest is used for testing.
Run pip install pytest
to install pytest.
Run tests with python -m pytest
from the repository root directory. Note this must be used rather than just pytest