Giter VIP home page Giter VIP logo

django-simpleapi's Introduction

Django-SimpleAPI Django Version

Running server

Clone:

HTTPS: https://github.com/endormi/django-simpleAPI.git or SSH: [email protected]: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"
    }
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.