$ pip install django
$ python manage.py runserver
See pera_be/urls.py.
You can run the backend using Docker with the following commands.
Run this in the project root:
docker build -t pera-backend .docker run -e SPEECH_KEY='dummy_test_key' -e SPEECH_REGION='dummy_test_region' -p 8000:8000 pera-backendNow, the app should be running at http://127.0.0.1:8000
To spin up both the Django app and a local Postgres DB together:
docker compose up --buildThis runs:
- web: your Django backend (on port 8000)
- db: Postgres 15 database (on port 5432)
Make sure you have a .env file in the root folder that looks like this:
SPEECH_KEY=our_azure_speech_key
SPEECH_REGION=our_azure_region
DB_NAME=pera_db
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
DB_PORT=5432
DB_SSL_MODE=disableFirst-time Setup (after running compose)
If you're making new models or updating existing ones:
docker compose exec web python manage.py makemigrationsRun migrations inside the web container:
docker compose exec web python manage.py migrateThat sets up the DB tables and you're good to go!
docker run --rm pera-backend pytestCheck container logs:
docker logs <container_id>docker exec -it <container_id> sh