Simple web admin interface to manage .json file
Project description
Json-admin
Библиотека с реализацией простого интерфейса для управления .json-файлом с настройками приложения.
Быстрый старт
from litestar import Litestar
from pydantic import BaseModel, Field
from jsonadmin import Admin, HtmlPage, JsonPage
class AppSettings(BaseModel):
"""Настройки приложения."""
debug: bool = Field(default=False, description="Включает debug-режим")
retries: int = Field(default=3, ge=0, description="Количество повторных попыток")
class FeatureFlags(BaseModel):
"""Настройки feature flags."""
use_cache: bool = Field(default=True, description="Включает кеширование")
beta_mode: bool = Field(default=False, description="Включает beta-режим")
app = Litestar(route_handlers=[])
admin = Admin(
app=app,
passwd="super-strong-password",
title="My App Admin",
index="index.html",
login="login.html",
pages=[
HtmlPage(
slug="info",
title="Информация",
icon="fa-solid fa-circle-info",
content="""
<h2>Welcome</h2>
<p>This page is read-only and renders embedded HTML block.</p>
""",
),
JsonPage(
slug="settings",
title="Настройки",
file_path="data/app_settings.json",
model=AppSettings,
icon="fa-solid fa-gear",
),
JsonPage(
slug="features",
title="Флаги",
file_path="data/feature_flags.json",
model=FeatureFlags,
icon="fa-solid fa-flag",
),
],
base_url="/",
)
После запуска:
GET /покажет форму входа по паролю.- после входа доступны вкладки-страницы с JSON-редактором.
HtmlPage— read-only вкладка с HTML-блоком.contentможет быть:- встроенной строкой HTML,
- путём к
.htmlфайлу, Callable[[], str].
- кнопка
Сохранитьвалидирует данные через обязательную Pydantic-модель и сохраняет JSON в файл. - можно переопределить интерфейс через Jinja-шаблоны в
jsonadmin/html/(по умолчанию) или черезtemplates_dir=.... - для вкладок можно передать
iconс классом Font Awesome, напримерfa-solid fa-gear.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_admin-0.1.0.tar.gz.
File metadata
- Download URL: json_admin-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e00a0d3d8dab3f94fa51845ce58472eea92cdd4d5c85848689b0598ed22079
|
|
| MD5 |
eb1b7777fc036f667e50c3b9dab977bf
|
|
| BLAKE2b-256 |
873c382348458f605c9fbe5d0dda3fc5f56646e0ebab6dc356e51d4b832c8149
|
Provenance
The following attestation bundles were made for json_admin-0.1.0.tar.gz:
Publisher:
pypi.yml on LoveBloodAndDiamonds/json-admin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
json_admin-0.1.0.tar.gz -
Subject digest:
93e00a0d3d8dab3f94fa51845ce58472eea92cdd4d5c85848689b0598ed22079 - Sigstore transparency entry: 996839866
- Sigstore integration time:
-
Permalink:
LoveBloodAndDiamonds/json-admin@5970b349a20a293e91905aa1677d93afc6c10896 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LoveBloodAndDiamonds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5970b349a20a293e91905aa1677d93afc6c10896 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file json_admin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: json_admin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95674db9bd71fb0e864f45c30dd89e965243d6042793c1142db6538810dec3de
|
|
| MD5 |
3de3ef14bf37f79d8cfe74333674d1fc
|
|
| BLAKE2b-256 |
68dc36a7c7680c3c1ed3d12d42e5d16d9ddd45999c5905012875a092f42286a0
|
Provenance
The following attestation bundles were made for json_admin-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on LoveBloodAndDiamonds/json-admin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
json_admin-0.1.0-py3-none-any.whl -
Subject digest:
95674db9bd71fb0e864f45c30dd89e965243d6042793c1142db6538810dec3de - Sigstore transparency entry: 996839931
- Sigstore integration time:
-
Permalink:
LoveBloodAndDiamonds/json-admin@5970b349a20a293e91905aa1677d93afc6c10896 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LoveBloodAndDiamonds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5970b349a20a293e91905aa1677d93afc6c10896 -
Trigger Event:
pull_request
-
Statement type: