Lightweight REST Sever framework, based on bottle
Project description
AJAS
Description
Another JSON Api Server. This is a library for Python 3 to create fast JSON-Rest APIs. It uses flask and gevent in the background.
Usage
A simple start:
from AJAS import Api
def simple_resolver(header, query):
return {"hello":"world"}
api = Api()
api.add_get_resolver("/hello", simple_resolver)
api.add_post_resolver("/hello", simple_resolver)
api.run("localhost", 8080)
This will run an webserver returning '{"hello":"world"}'
at the adress http://localhost:8080/hello
for both GET and POST requests.
Using blocks
Using blocks allows you to seperate different parts of your API. This can be used for versioning. Also, blocks can hold a authenticator, which can accept or deny a request based on the header and query of the reuest.
from AJAS import Api, Authenticator
class MyAuth(Authenticator):
def authenticate(self, header, query):
if someCheck() == True:
return True
else:
return False
def simple_resolver(header, query):
return {"hello":"world"}
api = Api()
v1 = Block("/v1")
v1.add_get_resolver("/hello", resolver)
api.add_block(v1)
api.run("localhost", 8080)
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
File details
Details for the file AJAS-0.2.3.tar.gz
.
File metadata
- Download URL: AJAS-0.2.3.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b238222fe09ece86232f9d8d0b210e7da07ff030fc526a1dc6604dca90bc9305 |
|
MD5 | 49fc0ac956b7d0fcb85bb2fccd569256 |
|
BLAKE2b-256 | 685b28f628aaff406c90efcd82a81d45cf8785f3fbaf75f88c750d49b45a5eb9 |
File details
Details for the file AJAS-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: AJAS-0.2.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ec580a206d31a161b7a7448f1bba354554c9f6d693cde37e1934aaed9535322 |
|
MD5 | 7e5b449fe605a18fc7c65ba39260f7c7 |
|
BLAKE2b-256 | b94235bbcce2fc7d405e024b522169ce83ff88e2e0dd4e8e083249a99bc05e6e |