Sun praise internal backend package.
Project description
spback (sun-praise backend) framework
This project is built on django-ninja
and django-ninja-extra
.
Usage
Create your django project, start with the command: django-admin startproject conf .
.
Update settings.py
If you need to use the feature of api
, you need to install django-ninja-extra>=0.20.7
, django-ninja-jwt>=5.3.1
.
Add spback
supported apps,
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# for example, "apis",
...
"ninja_extra", # for spback
]
API instance
create api instance.
from spback.urls import create_api
api = create_api()
JWT
If you want the JWT get authed, set the api with JWTAuth
.
from ninja_extra.router import Router
from ninja_jwt.authentication import JWTAuth
router = Router()
@router.get("/", auth=JWTAuth())
def protected_endpoint(request):
return {"message": "This is a protected endpoint."}
Error handler
register error handler
from spback.handler.errors import register_error_handler
api = register_error_handler(api)
Register to urls.py
With this code, the users could register django-ninja
to urls.py
api = create_api()
api = register_routers(api)
urlpatterns = [
path("", api.urls),
]
Register to conf/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("api.urls")),
]
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
spback-0.1.0.tar.gz
(10.2 kB
view details)
Built Distribution
spback-0.1.0-py3-none-any.whl
(16.2 kB
view details)
File details
Details for the file spback-0.1.0.tar.gz
.
File metadata
- Download URL: spback-0.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe95c2ea4bcc70cfd139ee229f08aa65c7f5fd433aaed0f003381d7d6a3d01d |
|
MD5 | 19df51cb23e34d34230950c555a980bd |
|
BLAKE2b-256 | 1c0ba2a46b1203a1ce8de12396f001c467e70379814a8bece79f654fbeaed55a |
File details
Details for the file spback-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: spback-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 607c1989073493e8c95cb98fbf2dd1c13d143d8499353271ffd90cb85d39bd55 |
|
MD5 | 53b8ec05548370031895d64e9ebd5fee |
|
BLAKE2b-256 | fe715b46707b094d56fd8209ac76cb16222f8c32b1b143962b8f8331e6e071fa |