Skip to content

rrgaya-zz/review-api

Repository files navigation

Reviews API

Build Status Coverage Status

This project is simple API.

Getting Started

This documentation shows how to install the development enviroment. This is Python3 and Django based project.

Tech Stack

  • Python3
  • Django
  • Django Rest framework

Prerequisites

This may differ between Linux and MacOs platform. So take a look on these links:

  • Python3 - Script programming language
  • Pip3 - Package manager for python
  • git - Source code version manager

Configuring the enviroment

If the Python2 is installed it will conflict with Python3, so you should create a virutal enviroment.

STEP 1: Get the source code

Create a folder to be the working directory and execute a git clone. If you don't have access or user, contact the Administrator.

#SSH
git@github.com:rrgaya/review-api.git

# HTTP 
https://github.com/rrgaya/review-api.git

STEP 2: Creating the environment

Access the folder created by git on the terminal shell and you must run the following command, where env is the name of the base directory for pip3 will install all project library without conflict or affect the machine libraries. Also will assure that only python3 will be running in the virtual environment.

$ python3 -m venv venv

STEP 3: Activating the virtual enviroment

Run this commmand in the same folder where the env folder is located.

$ source env/bin/activate

STEP 4: Installing the requirements

It's a good practice upgrade pip for the first time

$ pip3 install pip --upgrade

For the sake of simplicity all the requirements are in the file requirementes.txt

$ pip3 install  -r requirements.txt

Running the project

Every time you need to start the development enviroment to programming or test follow the step:

  1. Activate the virutal env
$ source venv/bin/activate
  1. To starting the project run this command.
$ python manage.py runserver

How to running the tests?

  1. To run the test, execute:
$ pytest
  1. To run the test with coverage, execute:
$ pytest --cov

Get Token API

$  http :8000/token/ username="" password="" 

Response:

HTTP/1.1 200 OK
Allow: POST, OPTIONS
Content-Length: 52
Content-Type: application/json
Date: Mon, 18 Nov 2019 18:01:03 GMT
Server: WSGIServer/0.2 CPython/3.7.5
X-Frame-Options: SAMEORIGIN

{
    "token": "a8011880f073443f75dfe3e6bf7d1ff49c4fe3be"
}

Ignore this Token, because this is example. Get the your Token.

Get Reviews in API

$ http :8000/api/ "Authorization:Token a8011880f073443f75dfe3e6bf7d1ff49c4fe3be"

Post an new Review

$ http POST :8000/api/post/ "Authorization:Token ac93c31f0ca3e758479520084dc1e8f3e4e41c4e" \  
company=1 \
rating=5 \
sumary="Sumary Example" \
title="Title Example" \

Superuser Access

User: admin
Pass: 2019@252

About

API Review

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages