This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Installation

$ pip install bottle-api

Basic Usage

json_endpoint decorator will make a function to JSON WebAPI endpoint. decorated function will return bottle.HTTPResponse.

see this sample web app:

#!python
from bottleapi import WebApiError
from bottleapi.jsonapi import json_endpoint
from bottle import Bottle, request

app = Bottle()

@json_endpoint
def devide():
    a = int(request.params['a'])
    b = int(request.params['b'])
    if b == 0:
        raise WebApiError('b cannot be zero', status=400)

    result = a / b
    return dict(value=result)

app.route('/devide', ['GET'], devide)

if you access /device?a=1&b=1, it will return 200 OK response with body:

{"status": "ok", "result": {"value": 1}}

with Content-Type application/json

but when you access device?a=1&b=0, you will get 400 BAD REQUEST response with body:

{"status": "error", "message": "b cannot be zero", "result": null}

If you want to use JSONP, you can specify callback function name with parameter(j by default) So accessing /device?a=4&b=2&j=my_callback will result:

my_callback({"status": "ok", "result": {"value": 2}});

If you dont like parameter or result data format, You can define your own formatters(success/error). See jsonapi.py for customized formatter example.

Release History

Release History

0.0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bottle-api-0.0.3.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Dec 4, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting