Following are the set-up requirements and instructions to run the app locally:
- Python 3.x
- Flask
- Flask-SQLAlchemy
- mysqlclient
- MySQL Server (or MariaDB/PostgreSQL if preferred)
- Werkzeug
- pytest (to run tests)
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate -
Install the required packages:
pip install -r requirements.txt
-
Set up MySQL Database:
- Install MySQL Server if it's not already installed (can be modified for PostgreSQL or MariaDB).
- Create a new database and user:
mysql -u root -p CREATE DATABASE <database-name>; CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>'; GRANT ALL PRIVILEGES ON <database-name>.* TO '<username>'@'localhost'; FLUSH PRIVILEGES; EXIT;
Enter your username and password in place of
<username>and<password>.
- Update the database URI:
- Modify the following line in your
app.pyfile:
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://<username>:<password>@<localhost>/<database-name>'
- Modify the following line in your
Make sure to configure the Database URL as per your database before running the project. Also substitute your credentials/port value in place of
<username>,<password>,<localhost>and<database-name>
- Initialize the database:
- Run the following command to create tables in the MySQL database:
python app.py
-
Start the Flask application:
python app.py
-
The application will be available at
http://127.0.0.1:5000.
GET /healthz: Health check endpoint. Logs the health check request to the database and returns a200 OKstatus if successful.
405 Method Not Allowed: Returned if the request method is notGET.400 Bad Request: Returned if the request contains data or form parameters.503 Service Unavailable: Returned if there is an error while inserting data into the database.
- Install
pytestin yourvenv
pip install pytest- Set the environment variable
TESTINGasTrueas follows for mac/Linux
export TESTING="True"or as follows for Windows
set TESTING=True- Run the test
pytest --verbosesudo aws acm import-certificate \
--certificate fileb://<path-to-certificate-file> \
--private-key fileb://<path-to-private-key-file> \
--certificate-chain fileb://<path-to-certificate-chain-file> \
--profile <aws-profile>Make sure to include the actual path of your respective files in the placeholder