kwikapi-tornado

Quickest way to build powerful HTTP APIs in Python


Keywords
kwikapi, meta
License
MIT
Install
pip install kwikapi-tornado==0.3.8

Documentation

kwikapi.tornado

Quickly build API services to expose functionality in Python. kwikapi.tornado was built by using the functionality of KwikAPI and Tornado web server.

Installation

$ pip3 install kwikapi[tornado]

Usage

Basic example to use kwikapi.tornado

sample.py

import tornado.ioloop
import tornado.web

from kwikapi.tornado import RequestHandler
from kwikapi import API

class BaseCalc(object):
    def add(self, a: int, b: int) -> int:
        return a + b

    def subtract(self, a: int, b: int) -> int:
        return a - b

api = API(default_version='v1')
api.register(BaseCalc(), 'v1')

def make_app():
    return tornado.web.Application([
        (r'^/api/.*', RequestHandler, dict(api=api)),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Run script

$ python sample.py

Make API request

$ curl "http://localhost:8888/api/v1/add?a=10&b=10"

To know how to use all features, please refer KwikAPI documentation https://github.com/deep-compute/kwikapi/blob/master/README.md