Giter Club home page Giter Club logo

bottle-cerberus's Introduction

Cerberus plugin

Cerberus plugin for bottle

installation

Via pip: pip install bottle-cerberus

Or clone: git clone https://github.com/agalera/bottle-cerberus.git

example:

from bottle import get, install, run
from bottle_cerberus import CerberusPlugin, Schema


class ExampleSchema(Schema):
    def schema(self):
        return {
            'ex': {'type': 'integer'},
            'url': {'ex': {'coerce': int}}
        }


class QuerySchema(Schema):
    def schema(self):
        return {'ex': {'coerce': int}}


@get('/cerberus/<ex>', schemas={'body': ExampleSchema(),
                                'query_string': QuerySchema())
def test_cerberus(ex):
    from bottle import request
    print("query_string", request.query['ex'], type(request.query['ex']))
    print("url", ex, type(ex))
    print("body", request.json.get('ex'), type(request.json.get('ex')))


install(CerberusPlugin())
run(host="0.0.0.0", port="9988")

Schemas

Optional keys

body: schema for request.json

url: schema for url (no query string)

query_string: schema for query strings

Schema

Github Schema: https://github.com/nicolaiarocci/cerberus Doc schema: http://docs.python-cerberus.org/en/stable/

bottle-cerberus's People

Contributors

agalera avatar pimtel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pimtel

bottle-cerberus's Issues

ImportError: cannot import name 'Hashable' from 'collections'

This error comes from Cerberus a required install. The pinned version is 1.0.1

I am using Python 3.10.4 (main, Jun 30 2022, 17:27:05) [Clang 13.1.6 (clang-1316.0.21.2.3)]

I cloned the repo locally and removed the pinned version for Cerberus. The install now works. I have version 1.3.4 installed.

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.