Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekampf/webapp2_restful
https://github.com/ekampf/webapp2_restful
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ekampf/webapp2_restful
- Owner: ekampf
- License: bsd-3-clause
- Created: 2015-07-14T02:46:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T19:44:36.000Z (about 2 years ago)
- Last Synced: 2024-12-09T09:58:56.951Z (29 days ago)
- Language: Python
- Size: 44.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
WebApp2 RequestParser
===============================.. image:: https://travis-ci.org/ekampf/webapp2_restful.svg
:target: https://travis-ci.org/ekampf/webapp2_restful.. image:: https://coveralls.io/repos/ekampf/webapp2_restful/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/ekampf/webapp2_restful?branch=master.. image:: https://img.shields.io/pypi/v/webapp2_restful.svg
:target: https://pypi.python.org/pypi/webapp2_restfulThe *webapp2_restful* library is a Request parsing interface inspired by `restful-flask's request parser `_.
Its interface is modeled after the `argparse `_ interface.
Its goal is to provide a uniform access to any variable on the webapp2.Request object and allowing handlers to provide a sort of "contract" where they
specify the parameters they expect to be called with - making code easier to read and understand.* Free software: BSD license
* Documentation: https://webapp2_restful.readthedocs.org.Basic Argument Parsing
----------------------Here’s a simple example of the request parser.
It looks for two arguments in the webapp2.Request's *json* and *params* properties: one of type int, and the other of type str:.. code::
from webapp2_restful.parser import RequestParser
parser = RequestParser()
parser.add_argument('rate', type=int, help='Rate cannot be converted')
parser.add_argument('name', type=str)
args = parser.parse_args(self.request)Special Google AppEngine Arguments
----------------------------------.. code::
from webapp2_restful.parser import RequestParser
from webapp2_restful.arguments_ndb import EntityIDArgumentparser = RequestParser()
parser.add_argument('store_id', type=EntityIDArgument(Store), dest='store')
args = parser.parse_args(self.request)# args.store is a Store instance
print(args.store)