Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

endormi/django-simpleAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django-SimpleAPI Django Version

Running server

Clone:

HTTPS: https://github.com/endormi/django-simpleAPI.git or SSH: git@github.com:endormi/django-simpleAPI.git

Install requirements:

pip install -r requirements.txt

Migrate:

py manage.py migrate

Runserver:

py manage.py runserver

Run tests:

py manage.py test api

Using Postman

Follow the running server example to get the server up and running.

Get all:

http://127.0.0.1:8000/movies/

By ID:

http://127.0.0.1:8000/movies/1

Using website

Follow the running server example to get the server up and running.

Go to this URL:

http://127.0.0.1:8000/movies/

Example of GET JSON:

[
    {
        "id": 1,
        "name": "The Matrix",
        "description": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
        "category": "Action, Sci-Fi",
        "director": "Lana Wachowski, Lilly Wachowski (as The Wachowski Brothers)",
        "main_actor": "Keanu Reeves",
        "release_date": "1999-03-31T00:00:00Z"
    }
]

Using Curl

Follow the running server example to get the server up and running.

Example response for the HTTP:

curl -iX GET http://localhost:8000/movies/

You should see something like this:

HTTP/1.0 200 OK
Date: Mon, 25 Feb 2019 ...
Server: WSGIServer/0.2 CPython/3.7.2
Content-Type: application/JSON

[
    {
        "id": 1,
        "name": "The Matrix",
        "description": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
        "category": "Action, Sci-Fi",
        "director": "Lana Wachowski, Lilly Wachowski (as The Wachowski Brothers)",
        "main_actor": "Keanu Reeves",
        "release_date": "1999-03-31T00:00:00Z"
    }
]

Also you should see details for the movie objects

It is similar with HTTPIE

Using HTTPIE

Follow the running server example to get the server up and running.

Install HTTPIE:

pip install httpie

Get the list of movies:

http http://127.0.0.1:8000/movies/

Example response:

HTTP/1.1 200 OK
...
[
    {
        "id": 1,
        "name": "The Matrix",
        "description": "A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.",
        "category": "Action, Sci-Fi",
        "director": "Lana Wachowski, Lilly Wachowski (as The Wachowski Brothers)",
        "main_actor": "Keanu Reeves",
        "release_date": "1999-03-31T00:00:00Z"
    }
]

About

Simple REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages