A small, RESTful api for quotes
- Ensure you have python >=3.10 installed
- Ensure you have poetry installed
- Run the build script by executing
source build.sh
from the project root - Launch the webserver with the command
poetry run ./manage.py runserver
Django provides an admin panel that you can use to do various things, most notably
edit the database (important as we are using sqlite3). Once you have run setup the
project you can run the command poetry run ./manage.py createsuperuser
and follow
the prompts to set up the admin account username and password
The model classes in models.py
control the schema of the underlying database.
If you change them (update, add, remote, etc.) make sure to run
poetry run ./manage.py makemigrations matchday
to generate the required migrations
to be applied to all dbs on startup.
You can load up some sample data by running the command
poetry run ./manage.py loaddata tests/unit/example_db.json
from the project root
Tests can be run using the command poetry run ./manage.py test
. Mock data is populated
via the json file example_db.json
Pull a random quote from the database
{
"quote": "Cheese is tasty",
"author": {
"first_name": "Mr.",
"last_name": "Mouse"
}
}
Pull all the authors from the database
{
"authors": [
{
"first_name": "Mr.",
"last_name": "Mouse"
}
]
}
{
"authors": []
}
Pull a random quote from the defined author from the database First name and last name must be provided in the url
{
"quote": "Cheese is tasty",
"author": {
"first_name": "Mr.",
"last_name": "Mouse"
}
}
Pull a random quote from the ZenQuotes API
{
"quote": "Cheese is tasty",
"author": {
"first_name": "Mr.",
"last_name": "Mouse"
}
}
- Make endpoints asynchronous, future proofs complicated work
- Dynamically generate the OpenAPI specification for all the endpoints