Django REST API that connects the validation-server-frontend with the validation-server-engine.
See cookiecutter-django-rest repository for more detail.
-
Front End Site (requires log-in):
https://validation-server-stg.urban.org
-
API (requires log-in):
https://validation-server-stg.urban.org/api/v1/
-
Documentation (requires log-in):
https://validation-server-stg.urban.org/api/swagger/
https://validation-server-stg.urban.org/api/swagger.[json | yaml]
https://validation-server-stg.urban.org/api/redoc/
** FOR LOCAL TESTING PURPOSES ONLY **
This requires an .env file with the following variables set:
MYSQL_DATABASE
MYSQL_ROOT_PASSWORD
MYSQL_USER
MYSQL_PASSWORD
Build your containers:
./deploy.sh -e development
If you have made changes to your models, make and apply the new migrations.
docker-compose run --rm web ./manage.py makemigrations
docker-compose run --rm web ./manage.py migrate
You can import from the backup sql dump:
docker-compose exec mysql bash ./scripts/import_mysql_backup.sh
And export:
docker-compose exec mysql bash ./scripts/export_mysql_backup.sh
Once the stack is up and running, create a super user login:
docker-compose run --rm web ./manage.py createsuperuser
From there you can navigate to http://0.0.0.0:8000
in your browser and login
using the credentials you just created.
Run a command inside the docker container:
docker-compose run --rm web [command]
To stop the stack:
docker-compose down
To run unit tests:
docker-compose run --rm web ./manage.py test
You can programatically hit the API. Note you will need to generate a token from the admin panel.
import requests
token = "[YOUR TOKEN HERE]"
headers = {"Authorization": f"Token {token}"}
r = requests.get("http://0.0.0.0:8000/api/v1/command/", headers = headers)
r.json()
- If the
swagger
orredoc
pages don't load properly, you may need to run:
docker exec -it web python manage.py collectstatic --noinput
to pull in the static js files from the drf-yasg
package.