Bottle-wrapper to make python objects accessible via HTTP API
Project description
Nimrodel
A simple Bottle.py-wrapper to provide HTTP API access to any python object.
Requirements
- python3 - GitHub
- bottle.py - GitHub
- waitress - GitHub
- doreah - GitHub (at least Version 0.9.1)
- parse - GitHub
Quick Start
Install with
pip install nimrodel
Create your API with
from nimrodel import API
myapi = API()
You may optionally pass a port number with port=42, a path with path="api" and whether you want to serve on IPv4 (IPv6=False).
You can also give the API object an existing bottle server (server=bottleobject), in which case your API will be served on the existing server. It is heavily recommended to also pass a path variable to separate API from regular routing of your server.
You may also pass a custom function with parsedoc=yourfunction that takes your method as input and returns a dictionary with the values desc for the function description, params for a dictionary of parameter names mapped to a dictionary and returns for a dictionary of the return value. Both return and param dictionaries can have the keys type and desc for data type and description respectively. By default nimrodel will attempt to parse your docstring according to the reST standard (Sphinx).
Then make any class accessible with a decorator.
@myapi.apiclass("group")
class Group:
def __init__(self,name,apipath,songs):
# some stuff
self.__apiname__ = apipath
Any instance of that class is now accessible via the combination of class path and its individual path. Now just decorate the methods. All its arguments can be passed via URI query arguments.
@myapi.get("songs")
def get_songs(self,member):
return {"songs":[s["title"] for s in self.songs if member in s["performers"]]}
Now create an object and make sure it has an __apiname__ attribute:
e = Group("Exid","exid",exidsongs)
Then you can access its methods with simple HTTP calls like /group/exid/songs?member=Junghwa.
There is also an integrated graphical API explorer under /api_explorer.
Nimrodel also allows you to create a simple function-based API with the class EAPI.
For more in-depth exploration of the possibilities, refer to the file example.py included in the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nimrodel-0.6.tar.gz.
File metadata
- Download URL: nimrodel-0.6.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
709df2f0cf8eee80c2188b89f88a62b129d8167a9648efdbcbc9aa9596cd8887
|
|
| MD5 |
4a22a9036c19bc6de745e7f19897a02b
|
|
| BLAKE2b-256 |
f510d9227c71b194f9e8a6fe7bb3764a5392cf8b560c1b123efd3a3c5d291424
|
File details
Details for the file nimrodel-0.6-py3-none-any.whl.
File metadata
- Download URL: nimrodel-0.6-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb25b7e2276bc6fe12e37ac1d2c0f8ab2349f0b6f67581d5bfd76cb3e6f54c5d
|
|
| MD5 |
101acaa7ad028e27e63867e2f4dfb09c
|
|
| BLAKE2b-256 |
b1755548f6e5638bf5608f508e01b7282970904576118483f8edb6489cd7a291
|