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),
...
}
Metadata
Release files for nekoite-be-core 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nekoite-be-core-0.1.4.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nekoite_be_core-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / nekoite-be-core-0.1.4.tar.gz
| Download URL | nekoite-be-core-0.1.4.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc2702a3897e6384a30225bf471dc5f73e744da00e3fe52dc818fc65e34a0fdb
|
|
BLAKE2b-256 checksum How to use checksums |
0e699a073d1b19a7ecfa72a8818b04a8b817ae87155ea48109e10d8922cc93df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Release files / nekoite_be_core-0.1.4-py3-none-any.whl
| Download URL | nekoite_be_core-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9080ff7bc596a2098559f462f93aa004303bf447196e025086e72ce3aa3139c
|
|
BLAKE2b-256 checksum How to use checksums |
ecb86b22e7bcb67aa86d12c2dd72fdfc7c8a75cf6b283573f396dc007f863567
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|