From a2d473416e3144a7c3982f055a17182377ced04b Mon Sep 17 00:00:00 2001 From: RamanjaneyuluIdavalapati Date: Wed, 7 Feb 2018 17:31:59 +0530 Subject: [PATCH] README improved --- .travis.yml | 5 +++-- README.md | 56 ++++++++++++++++++++++++++++++++++++----------------- setup.py | 6 +++--- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index c422e1d..c43c3a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ script: - echo "No tests as of now" deploy: - provider: releases + skip_cleanup: true api_key: secure: szU2C7KG3GzWO6x5RleHRf+/OpKvZWpN9Z+JPYb0xr+oSCQfms5/kMG8tTBUxjm5exv6xRsnknAa0vL+DqyeNEo8bPBYt3ZoDbB9pTqZhYuKSqDQnAP9N7xrmaXK7AVtuY07zDVToI6M0pWaqn+7A5YG0c9lqt3EuaCbSosqShzoDEZvO9bY1q4tsmjrP7hC28phsOuXCRzBBSabXEueyNeJInDTVFjfxp+yD1du3zIC1Qy4hi1rurTROSogKVWaChVcR9JJdAdawG/5J4QULtuma8fBvo2GhrJSH6ofTsLI1LXo64IixXqhb+FoAbABMjDkukjOXfOgiovGeay5n1PFuenFvQY3T3OscGJId16HeQPJ8BPd6U1k0b57Ij9Fl2nraUSIVpoC3tpBfyhMfXyF08ZEfXIJJwQl1BU96EZXt7PpgY7Mh9MwUnKh6SZ6E9ykwp1jVQ+YSS47u5nWpdAr6DYkjrCfwxw9hOWqH1tgyiSNw1u0xpA7qWUAl8JrEQrrq1EG9buGrH3aeF0p4eyTg38IdqQGhXNWLVJzo4U+QdVT930hDE6CCwhvc5otFiBKqED3ZAidAOJOq4ECZLPOGc8YIvd/4LXZTsaZEfQ1ovAqJnxTOvS5TnarAGI4CO8OvyqTN3nRdzrcMcYkdK5xyoG/jqHPD2jB3H/5Sls= file: @@ -16,8 +17,8 @@ deploy: - kwikapi/__init__.py - kwikapi/django/__init__.py - kwikapi/django/kwikapi_django.py - name: kwikapi.django-0.0.1 - tag_name: 0.0.1 + name: kwikapi.django-0.1 + tag_name: 0.1 on: repo: deep-compute/kwikapi.django - provider: pypi diff --git a/README.md b/README.md index 0e30039..f3ee4f8 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,31 @@ -# Use kwikapi in Django +# kwikapi.django + +Quickly build API services to expose functionality in Python. `kwikapi.django` was built by using the functionality of KwikAPI and Django web server. + +## Installation -## Install kwikapi for Django ```bash $ pip install kwikapi[django] ``` -## Create a Django project (Ref: https://docs.djangoproject.com/en/1.9/intro/tutorial01/) +## Usage + +### Create a Django project + +(Ref: https://docs.djangoproject.com/en/1.9/intro/tutorial01/) + ```bash $ django-admin startproject django_kwikapi ``` -## Create an app in Django +### Create an app in Django + ```bash $ python manage.py startapp polls -`` +``` + +### Add your app name to settings.py -#### Add your app name to settings.py ```python INSTALLED_APPS = [ 'django.contrib.admin', @@ -27,7 +37,10 @@ INSTALLED_APPS = [ 'polls', ] ``` -## /django_kwikapi/django_kwikapi/urls.py +### Make sure the contents of files be like this + +/django_kwikapi/django_kwikapi/urls.py + ```python from django.conf.urls import url, include from django.contrib import admin @@ -38,36 +51,40 @@ urlpatterns = [ ] ``` -## /django_kwikapi/polls/urls.py +/django_kwikapi/polls/urls.py + ```python from django.conf.urls import url, include from . import views -from kwikapi.django import RequestHandler +from kwikapi_django import RequestHandler urlpatterns = [ url(r'api/', RequestHandler(views.api).handle_request), ] ``` -## /django_kwikapi/polls/views.py +### Example of django views + +/django_kwikapi/polls/views.py + ```python from django.http import HttpResponse from kwikapi import API from logging import Logger class BaseCalc(): - def add(self, a: int, b: int) -> int: + def add(self, request, a: int, b: int): return a + b - def subtract(self, a: int, b: int) -> int: + def subtract(self, request, a: int, b: int): return a - b class StandardCalc(): - def multiply(self, a: int, b: int) -> int: + def multiply(self, request, a: int, b: int): return a * b - def divide(self, a: int, b: int) -> int: + def divide(self, request, a: int, b: int): return a / b api = API(Logger, default_version='v1') @@ -75,15 +92,18 @@ api.register(BaseCalc(), 'v1') api.register(StandardCalc(), "v2") ``` -## Start Django +### Start Django + ```bash $ python manage.py makemigrations $ python manage.py migrate $ python manage.py runserver 8888 ``` -## Make API request +### Make API request + ```bash -$ curl http://localhost:8888/api/v1/add?a=10&b=10 -$ curl http://localhost:8888/api/v2/divide?a=10&b=10 +$ 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 diff --git a/setup.py b/setup.py index da6121c..88fdf80 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ from setuptools import setup, find_packages -version = '0.0.1' +version = '0.1' setup( - name="kwikapi_django", + name="kwikapi-django", version=version, packages=find_packages("."), package_dir={'kwikapi_django': 'django'}, @@ -14,7 +14,7 @@ author='Deep Compute, LLC', author_email='contact@deepcompute.com', install_requires=[ - 'django==1.9', + 'django==1.11', ], classifiers=[ 'Environment :: Web Environment',