GithubHelp home page GithubHelp logo

djangorest's Introduction

django REST

Simple django rest application for demostration and learning purposes built with django rest framework

Prerequisites

Libraries
virtualenv
pip
django
Database

This project use internal SQLite database, so there is no need for database setup. If you want to change database you can do it in settings.py file.

Installation

Clone project
git clone https://github.com/matoxxx/djangoREST.git

Navigate to:

cd djangoREST
Create virtual enviroment
virtualenv env  
Activate virtual enviroment

on Windows:

cd env/Scripts
activate

on Unix:

source env/bin/activate
Install dependencies:
pip install -r requirements.txt
Migrate database:
python manage.py migrate
Create root user:
python manage.py createsuperuser

Usage:

Run server:
python manage.py runsever <ip:port>			# example: python manage.py runserver 127.0.0.1:8000
REST API:

Django REST framework offers their own REST api via browser: http://127.0.0.1:8000/snippets/

Requests with httpie library:
http http://127.0.0.1:8000/snippets/
http http://127.0.0.1:8000/users/ Accept:text/html
http http://127.0.0.1:8000/users/ Accept:application/xml
http http://127.0.0.1:8000/snippets.json
http http://127.0.0.1:8000/users.api
Using HTTP methods:
http <GET | POST | PUT | DELETE | OPTIONS | HEAD> http://127.0.0.1:8000/snippets/
Post using form data:
http --form POST http://127.0.0.1:8000/snippets/ code="print 123"
Post using JSON:
http --json POST http://127.0.0.1:8000/snippets/ code="print 456"
Using authentication:
http -a matej:password POST http://127.0.0.1:8000/snippets/ code="print 789"

Author

Matej Hocevar @matoxxx

djangorest's People

Contributors

matejhocevar avatar matoxxx avatar

Watchers

 avatar  avatar

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.