A backend core utility library.
Reason this release was yanked:
bug
Project description
Nekoite Backend Core
Usage
Requires python 3.7 or newer.
pip install nekoite-be-core
There are some examples to look at.
Basically, choose an adapter (or build on your own), create
some views and routes, and give it to the function register_routes
.
routes = {"/a": AView, ...}
adapter = SomeAdapter(*args)
register_routes(adapter, routes)
Modules
View
Extend the class ViewBase
. Override the function handle_req
.
You can specify the request_schema
and response_schema
, and if they
are not specified or None
, then the request or response format will
not be checked. method
can be a string or list of strings indicating
the HTTP methods accepted by this view.
class TestView(ViewBase):
request_schema = {"id": fields.Integer(required=True)}
response_schema = {"id": fields.Integer(), "timestamp": fields.Integer()}
methods = ["GET", "POST"]
def handle_req(self, req: t.Dict[str, t.Any]) -> t.Any:
return {
"id": req["id"],
"timestamp": int(time()),
}
Fields
You can import fields
from this package. It includes some field type
defined in marshmallow
, and the Nested
type is rewritten to accept dict
as parameter.
The detailed usage of the types in fields
can be found on
the homepage of marshmallow.
from nekoite_be_core import fields
# ...
request_schema = {
"id": fields.Integer(required=True),
...
}
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
Hashes for nekoite_be_core-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9088fda7be1d0d5cd80879b734f8faf5da89c6fc93f52439c2faaddeb72ef287 |
|
MD5 | ee2ce622c8cd6114bccfa387c0f6c671 |
|
BLAKE2b-256 | 2d13913de842b0b4f8a4e09d2a0add46039f632d62551a459d3093bdb32f5743 |