Giter Site home page Giter Site logo

brat's Introduction

A framework of RESTful API based on Tornado

____________________    ________________
\______   \______   \  /  _  \__    ___/
 |    |  _/|       _/ /  /_\  \|    |   
 |    |   \|    |   \/    |    \    |   
 |______  /|____|_  /\____|__  /____|   
        \/        \/         \/          

Build Status

Installation

git clone [email protected]:iamsk/brat.git
cd brat
python setup.py install

Requirements

  • python 2.6 or 2.7
  • tornado
  • ujson
  • requests

Minimal Demo

$ more examples/miminal.py

from brat import Brat
from brat import BratHandler

brat = Brat()


class HelloWorld(BratHandler):
    def get(self):
        return {'hello': 'world'}

brat.add_handler('/', HelloWorld)

if __name__ == '__main__':
    brat.run()

$ python miminal.py

{"hello": "world"}

Completion Demo

store in examples/demo which use buildout for building application

$ ls examples/demo/src

app.py: used for the enter of the application
views.py: used for handlers of the application
models.py: used for data

$ bin/doc_gen init & bin/doc_gen

used for generate docs for api
  1. write options method for each handler
  2. change your docs/doc.conf

you will see doc at docs/doc.html

$ curl http://localhost:7778/users -X POST -u test:test -d 'email=[email protected]&password=test1'

{"email":"[email protected]","id":1,"password":"test1"}

$ curl http://localhost:7778/users -X GET -u test:test

{
     "paging":{"next":"http://localhost:7778/users?limit=10&offset=20",
     "previous":"http://localhost:7778/users?limit=10&offset=0"},
     "data":[{"email":"[email protected]","id":1,"password":"test1"}]
}

$ curl http://localhost:7778/users/1 -X GET -u test:test

{"email":"[email protected]","id":1,"password":"test1"}

$ curl http://localhost:7778/users/1 -X DELETE -u test:test

{}

brat

'brat' is the acronym of '__B__rat is a [framework|practice] of __R__estful __A__pi based on __T__ornado'.

brat's People

Contributors

iamsk avatar

Stargazers

 avatar  avatar

Watchers

 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.