This project is a Python Flask API that generates random compliments directed at "you" (the reader of the compliment). The compliments are pieced together from different parts of sentences to form complete sentences, ensuring they are never inappropriate, racist, or sexist. The API is capable of generating millions of unique compliments with a few different grammatical structures and is designed to be fast and reliable. The sentence parts are stored in text files, and no database is used.
To set up the development environment for this project, follow these steps:
- Ensure Python 3.10 or later is installed on your system.
- Clone the repository to your local machine.
- Navigate to the cloned repository directory.
- Create a virtual environment with
python -m venv venv
. - Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On Unix or MacOS:
source venv/bin/activate
- On Windows:
- Install the required dependencies with
pip install -r requirements.txt
. - Run the Flask application with
flask run
.
To interact with the API, send a GET request to the /compliment
endpoint. The API will return a JSON object containing a random compliment.
Example request:
GET /compliment HTTP/1.1
Host: <API_HOST>
Example response:
{
"compliment": "You always bring out the best in others."
}
To perform user acceptance testing, follow these steps:
- Ensure the Flask application is running by executing
flask run
. - Send a GET request to the
/compliment
endpoint using a tool likecurl
or Postman. - Verify that the response contains a
compliment
field with a string value. - Test multiple requests to ensure a variety of compliments are generated.
- Confirm that the compliments are appropriate and adhere to the project's guidelines.
Example command for testing with curl
:
curl -X GET http://localhost:5000/compliment
Test-Driven Development (TDD) is used throughout this project. To run the tests, execute the following command from the repository root:
pytest
Ensure all tests pass before pushing changes to the repository.
This project is licensed under the MIT License - see the LICENSE file for details.