Skip to main content

Sun praise internal backend package.

Project description

spback (sun-praise backend) framework

PyPI Documentation Status Downloads

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")),
]

For Developer

Use pdm run pip install -r requirements/requirements.dev to install dev packages.

Project details


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.2.4.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spback-0.2.4-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file spback-0.2.4.tar.gz.

File metadata

  • Download URL: spback-0.2.4.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for spback-0.2.4.tar.gz
Algorithm Hash digest
SHA256 536b4edffade4209f1f33741b0cd5b39dfb0f122a42f685aa5f72fc0021ab57d
MD5 0f4ed1a206908acb176e552537ff328c
BLAKE2b-256 569ad0d00da61839eae036c4d9b8e06416762637ca9785162990ecbbebcd824f

See more details on using hashes here.

File details

Details for the file spback-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: spback-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for spback-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 48866e328ec9a2ba8d45a74738f94bebe47bd1ba65da216f3b5475ec76dd5008
MD5 7fb4fdf40d4c0cac5ca70804a5a7748b
BLAKE2b-256 65e2900387838c00b7345ca0e23baf299d2059d79fef45fcf623d2bd3fb0b968

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page