A web application made using Python 3, Django 2, Django Rest Framework and PostgreSQL.
Application allows creating users, generating tokens and performing CRUD operations on Message model.
- creating users
- generating tokens
- creating, updating, displaying and deleting messages
- Python 3.7
- Django 2.2
- Django Rest Framework
- PostgreSQL
To run this project locally:
- In docker-compose.yaml replace
temporary_secret_key
with your own secret key (https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/#secret-key) - Start containers with
docker-compose up
- Application will be available at
http://0.0.0.0:8000/
- Create user
POST
https://short-messages-api.herokuapp.com/api/v1/user/create/
- Request token
POST
https://short-messages-api.herokuapp.com/api/v1/user/token/
- Message list
GET
https://short-messages-api.herokuapp.com/api/v1/message/list/
- Message details
GET
https://short-messages-api.herokuapp.com/api/v1/message/details/4 <message_id>
- Create message (require authorizations)
POST
https://short-messages-api.herokuapp.com/api/v1/message/create/
- Update message (require authorizations)
PUT
https://short-messages-api.herokuapp.com/api/v1/message/update/4 <message_id>
- Delete message (require authorizations)
DELETE
https://short-messages-api.herokuapp.com/api/v1/message/delete/4 <message_id>
To use endpoints which require authorization, token must be added to request header. To do that:
- Create new user https://short-messages-api.herokuapp.com/api/v1/user/create/
- Request token https://short-messages-api.herokuapp.com/api/v1/user/token/
- Add
Token <generated_token>
as 'Authorization' header
To deploy application to Heroku:
- Sign up to Heroku account and install Heroku CLI https://devcenter.heroku.com/articles/heroku-cli
- In Heroku dashboard create new application
- In CLI connect to remote of your application
heroku git:remote -a <your-application-name>
- Log in to Container Registry
heroku container:login
- Build a local image with correct tag
docker build -t registry.heroku.com/<your-application-name>/web .
- Push your secret key
heroku config:set SECRET_KEY=SOME_SECRET_VALUE -a <your-application-name>
- Create and connect PostgreSQL
heroku addons:create heroku-postgresql:hobby-dev -a <your-application-name>
- Push local image to Heroku registry
docker push registry.heroku.com/<your-application-name>/web
- Release changes
heroku container:release -a <your-application-name> web
- Run
manage.py migrate
on Heroku
heroku run python manage.py migrate