Skip to content

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.

Notifications You must be signed in to change notification settings

dawidbudzynski/short-messages-api

Repository files navigation

Short Messages API

General info

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.

Main functions

  • creating users
  • generating tokens
  • creating, updating, displaying and deleting messages

Technologies

  • Python 3.7
  • Django 2.2
  • Django Rest Framework
  • PostgreSQL

Setup

To run this project locally:

  1. 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)
  2. Start containers with
docker-compose up
  1. Application will be available at http://0.0.0.0:8000/

Endpoints

Create user image

Request token image

Message list image

Message detail image

Create message image

Update message image

Delete message image

Authorization

To use endpoints which require authorization, token must be added to request header. To do that:

  1. Create new user https://short-messages-api.herokuapp.com/api/v1/user/create/
  2. Request token https://short-messages-api.herokuapp.com/api/v1/user/token/
  3. Add Token <generated_token> as 'Authorization' header

Add token image

Heroku deployment

To deploy application to Heroku:

  1. Sign up to Heroku account and install Heroku CLI https://devcenter.heroku.com/articles/heroku-cli
  2. In Heroku dashboard create new application
  3. In CLI connect to remote of your application
heroku git:remote -a <your-application-name>
  1. Log in to Container Registry
heroku container:login
  1. Build a local image with correct tag
docker build -t registry.heroku.com/<your-application-name>/web .
  1. Push your secret key
heroku config:set SECRET_KEY=SOME_SECRET_VALUE -a <your-application-name>
  1. Create and connect PostgreSQL
heroku addons:create heroku-postgresql:hobby-dev -a <your-application-name>
  1. Push local image to Heroku registry
docker push registry.heroku.com/<your-application-name>/web
  1. Release changes
heroku container:release -a <your-application-name> web
  1. Run manage.py migrate on Heroku
heroku run python manage.py migrate

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published