Code Monkey home page Code Monkey logo

cookiecutter-flask-restful's Introduction

Cookiecutter Flask RESTful

This is a basic boilerplate app that can be used with Cookiecutter to scaffold new flask restful application.

If you find a bug in project, please open a ticket.

Installation and Usage

$ mkdir ~/flaskProjects
$ cd flaskProjects
$ virtualenv venv
$ source venv/bin/activate
(venv) $ cookiecutter gh:xk0nsid/cookiecutter-flask-restful

Answer the asked questions properly.

(venv) $ cd project_name
(venv) $ pip install -r requirements.txt
(venv) $ python manage.py db init
(venv) $ python manage.py db migrate
(venv) $ python manage.py db upgrade
(venv) $ python manage.py runserver

Features

The app comes with some basic stuff. Like Basic user model. Basic views for the user etc. Below is the list of avalable endpoints

Endpoints

URI Protected HTTP Method Action
/version/users/ Yes GET Get list of all users
/version/users/ No POST Create a new user
/version/users/ No OPTIONS Help for the given endpoint
/version/users/user_id Yes GET Get data of a single user
/version/users/user_id No OPTIONS Help for the given endpoint
/auth/ No GET Request auth token

Usage of Protected Routes

Create a user first

(venv) $ http POST http://localhost:5000/v1.0/users/ first_name="firstname"
last_name="lastname" username="username" password="password"

# Response should be something like this.
HTTP/1.0 201 CREATED
API-Version: 1.0
Content-Length: 169
Content-Type: application/json
Date: Wed, 29 Jul 2015 06:08:22 GMT
Location: http://localhost:5000/v1.0/users/username
Server: Werkzeug/0.10.4 Python/2.7.6

{
    "first_name": "firstname",
    "id": 1,
    "last_name": "lastname",
    "location": "http://localhost:5000/v1.0/users/username",
    "username": "username"
}

Get Auth Token for that user

(venv) $ http POST http://localhost:5000/auth username="username"
password="password"

# Response
HTTP/1.0 200 OK
Content-Length: 146
Content-Type: application/json
Date: Wed, 29 Jul 2015 06:11:17 GMT
Server: Werkzeug/0.10.4 Python/2.7.6

{
    "token": "auth_token"
}

Access protected routes

(venv) $ http GET http://localhost:5000/v1.0/users/ "Authorization: Bearer
auth_token"

cookiecutter-flask-restful's People

Contributors

xk0nsid 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.