Skip to content

KacperKotlewski/Cars_API

Repository files navigation

Cars API

This project is a REST API made as a task from Netguru

Overview

Requirements

Setup

Firstly you need to have required programs

  1. Clone/download the repository
  2. Enter inside project directory on your machine
  3. Create .env file based on .env-example click here to read more
  4. Build docker compose, terminal example: docker-compose build
  5. Now you can run or test project

.env configuration

To create .env file follow these steps:

  1. Copy .env-example as .env
    - Linux(Debian) terminal example: cp .env-example .env
  2. Edit .env file
    - Linux(Debian) terminal example: nano .env
  3. Set boolean DJANGO_DEBUG (TRUE or FALSE)
  4. Set ALLOWED_HOSTS with your IP's or/and sides (if you want to add more than one use comma symbol if you want to allow all use asterisk symbol)
  5. Additional, non-required in final .env file:
    • Add DATABASE_URL as URL to your DB (by default Django will create SQLite DB file after run app)
    • Add DJANGO_SECRET_KEY (by default Django will generate random key each time you run the app)

.env file should look like this:

DJANGO_DEBUG=FALSE
ALLOWED_HOSTS=localhost, 0.0.0.0, other_ip, some-side.com, *
DJANGO_SECRET_KEY=your-key-here
DATABASE_URL=your-db_url-here

Back to setup
Back to overview

Run project

Firstly setup project
To run the project using this command: docker-compose up

Back to setup
Back to overview

Test REST API

Firstly setup project
To run tests use this command: docker-compose run app bash -c "python manage.py test"
If the command above doesn't work use this instead: docker-compose run app bash -c "python manage.py test api"

Back to setup
Back to overview

Used technologies

Technologies:

Python frameworks & libraries:

  • django - the framework for web apps (I did not learn other web apps frameworks for python like Flask because I think Django is the most community supported and brilliant for big project usage)
  • django rest framework - the framework for REST API's compatible with Django, is must have for REST API projects because of features that are provided for the developer's usage
  • drf-yasg - easy to use docs generator for Django REST framework, also must have for REST API project in my opinion, because that provides us easy to read and use for humans docs like swagger or redoc
  • requests - used to validate data by requesting cars from used vehicle API
  • django-environ, python-decouple, dj_database_url - for statics files and reading .env file values
  • psycopg2 - required PostgreSQL library

Back to overview

About

recruitment task from netguru

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published