Name | fastapi-config JSON |
Version |
0.1.0
JSON |
| download |
home_page | |
Summary | FastAPI-Config is a visual dynamic configuration management extension based on FastAPI-Amis-Admin. |
upload_time | 2023-07-11 09:32:26 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
fastapi-amis-admin
fastapi-config
python-config
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[简体中文](https://github.com/amisadmin/fastapi_config/blob/master/README.zh.md)
| [English](https://github.com/amisadmin/fastapi_config)
<h2 align="center">
FastAPI-Config
</h2>
<p align="center">
<a href="https://pypi.org/project/fastapi-config" target="_blank">
<img src="https://badgen.net/pypi/v/fastapi-config?color=blue" alt="Package version">
</a>
<a href="https://pepy.tech/project/fastapi-config" target="_blank">
<img src="https://pepy.tech/badge/fastapi-config" alt="Downloads">
</a>
<a href="https://gitter.im/amisadmin/fastapi-amis-admin">
<img src="https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg" alt="Chat on Gitter"/>
</a>
<a href="https://jq.qq.com/?_wv=1027&k=U4Dv6x8W" target="_blank">
<img src="https://badgen.net/badge/qq%E7%BE%A4/229036692/orange" alt="229036692">
</a>
</p>
## Project Introduction
`Fast API-Config` is a visual dynamic configuration management extension package based on `FastAPI-Amis-Admin`.
## Install
```bash
pip install fastapi-config
```
## Simple example
**main.py**:
```python
from fastapi import FastAPI
from fastapi_amis_admin import amis
from fastapi_amis_admin.admin import Settings, AdminSite
from fastapi_amis_admin.models import Field
from fastapi_config import ConfigModelAdmin, DbConfigStore, ConfigAdmin
from sqlmodel import SQLModel
from pydantic import BaseModel
from typing import List
# Create a `FastAPI` application
app = FastAPI()
# Create `AdminSite` instance
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))
# Create a configuration repository
dbconfig = DbConfigStore(site.db)
# Register Admin (optional)
site.register_admin(ConfigModelAdmin)
class ContactCfg(BaseModel):
name: str = Field("", title="Name")
qq: List[str] = Field("", title="QQ")
class SiteCfg(BaseModel):
name: str = Field(..., title="Site Name")
logo: str = Field("", title="Site LOGO", amis_form_item=amis.InputImage())
contacts: List[ContactCfg] = Field([], title="Contact list")
domains: List[str] = Field([], title='Domain list')
class SiteCfgAdmin(ConfigAdmin):
page_schema = amis.PageSchema(label='Site Config')
schema = SiteCfg
site.register_admin(SiteCfgAdmin)
@app.get('/config')
async def read_config():
return await dbconfig.get(SiteCfg)
@app.on_event("startup")
async def startup():
# Mount the site to the FastAPI instance
site.mount_app(app)
# Create database tables (required for first run)
await site.db.async_run_sync(SQLModel.metadata.create_all, is_session=False)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, debug=True)
```
## Interface/UI Preview
- Open `http://127.0.0.1:8000/admin/` in your browser:
![SchedulerAdmin](https://img-blog.csdnimg.cn/0e3b49a10f2d4f65977b60b3fc35057f.png#pic_center)
## Dependent project
- [FastAPI-Amis-Admin](https://docs.amis.work/)
## License
The project follows the Apache2.0 license agreement.
Raw data
{
"_id": null,
"home_page": "",
"name": "fastapi-config",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "FastAPI-Amis-Admin,FastAPI-Config,Python-Config",
"author": "",
"author_email": "Atomi <1456417373@qq.com>",
"download_url": "https://files.pythonhosted.org/packages/30/7e/9bfb94cc068607b289022891fdd309e15c9b0e62533568bc9073bd06269c/fastapi-config-0.1.0.tar.gz",
"platform": null,
"description": "[\u7b80\u4f53\u4e2d\u6587](https://github.com/amisadmin/fastapi_config/blob/master/README.zh.md)\n| [English](https://github.com/amisadmin/fastapi_config)\n\n<h2 align=\"center\">\n FastAPI-Config\n</h2>\n<p align=\"center\">\n <a href=\"https://pypi.org/project/fastapi-config\" target=\"_blank\">\n <img src=\"https://badgen.net/pypi/v/fastapi-config?color=blue\" alt=\"Package version\">\n </a>\n <a href=\"https://pepy.tech/project/fastapi-config\" target=\"_blank\">\n <img src=\"https://pepy.tech/badge/fastapi-config\" alt=\"Downloads\">\n </a>\n <a href=\"https://gitter.im/amisadmin/fastapi-amis-admin\">\n <img src=\"https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg\" alt=\"Chat on Gitter\"/>\n </a>\n <a href=\"https://jq.qq.com/?_wv=1027&k=U4Dv6x8W\" target=\"_blank\">\n <img src=\"https://badgen.net/badge/qq%E7%BE%A4/229036692/orange\" alt=\"229036692\">\n </a>\n</p>\n\n## Project Introduction\n\n`Fast API-Config` is a visual dynamic configuration management extension package based on `FastAPI-Amis-Admin`.\n\n## Install\n\n```bash\npip install fastapi-config\n```\n\n## Simple example\n\n**main.py**:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_amis_admin import amis\nfrom fastapi_amis_admin.admin import Settings, AdminSite\nfrom fastapi_amis_admin.models import Field\nfrom fastapi_config import ConfigModelAdmin, DbConfigStore, ConfigAdmin\nfrom sqlmodel import SQLModel\nfrom pydantic import BaseModel\nfrom typing import List\n\n# Create a `FastAPI` application\napp = FastAPI()\n\n# Create `AdminSite` instance\nsite = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))\n\n# Create a configuration repository\ndbconfig = DbConfigStore(site.db)\n\n# Register Admin (optional)\nsite.register_admin(ConfigModelAdmin)\n\n\nclass ContactCfg(BaseModel):\n name: str = Field(\"\", title=\"Name\")\n qq: List[str] = Field(\"\", title=\"QQ\")\n\n\nclass SiteCfg(BaseModel):\n name: str = Field(..., title=\"Site Name\")\n logo: str = Field(\"\", title=\"Site LOGO\", amis_form_item=amis.InputImage())\n contacts: List[ContactCfg] = Field([], title=\"Contact list\")\n domains: List[str] = Field([], title='Domain list')\n\n\nclass SiteCfgAdmin(ConfigAdmin):\n page_schema = amis.PageSchema(label='Site Config')\n schema = SiteCfg\n\n\nsite.register_admin(SiteCfgAdmin)\n\n\n@app.get('/config')\nasync def read_config():\n return await dbconfig.get(SiteCfg)\n\n\n@app.on_event(\"startup\")\nasync def startup():\n # Mount the site to the FastAPI instance\n site.mount_app(app)\n # Create database tables (required for first run)\n await site.db.async_run_sync(SQLModel.metadata.create_all, is_session=False)\n\n\nif __name__ == '__main__':\n import uvicorn\n\n uvicorn.run(app, debug=True)\n```\n\n## Interface/UI Preview\n\n- Open `http://127.0.0.1:8000/admin/` in your browser:\n\n![SchedulerAdmin](https://img-blog.csdnimg.cn/0e3b49a10f2d4f65977b60b3fc35057f.png#pic_center)\n\n## Dependent project\n\n- [FastAPI-Amis-Admin](https://docs.amis.work/)\n\n## License\n\nThe project follows the Apache2.0 license agreement.\n\n",
"bugtrack_url": null,
"license": "",
"summary": "FastAPI-Config is a visual dynamic configuration management extension based on FastAPI-Amis-Admin.",
"version": "0.1.0",
"project_urls": {
"-Source": "https://github.com/amisadmin/fastapi_config",
"FastAPI-Amis-Admin": "https://github.com/amisadmin/fastapi_amis_admin"
},
"split_keywords": [
"fastapi-amis-admin",
"fastapi-config",
"python-config"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b746244ad4b04dc786d46589a80e379bd126961a4a325ef1aff7b50e9a05f247",
"md5": "7ae6c9982fc06e29b6c9acb2b02de1e1",
"sha256": "cf935432b00e549abc773097e397d9224e6fded4dae5ac24589753190e5f57d8"
},
"downloads": -1,
"filename": "fastapi_config-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7ae6c9982fc06e29b6c9acb2b02de1e1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 31430,
"upload_time": "2023-07-11T09:32:25",
"upload_time_iso_8601": "2023-07-11T09:32:25.050812Z",
"url": "https://files.pythonhosted.org/packages/b7/46/244ad4b04dc786d46589a80e379bd126961a4a325ef1aff7b50e9a05f247/fastapi_config-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "307e9bfb94cc068607b289022891fdd309e15c9b0e62533568bc9073bd06269c",
"md5": "416d567ed88fe0b3f2a5f98e946a2e65",
"sha256": "a1d9bc1262ff0fb0ad8668b58ecc87b2c78114f84e9a5badf04baeb04b028497"
},
"downloads": -1,
"filename": "fastapi-config-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "416d567ed88fe0b3f2a5f98e946a2e65",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 22959,
"upload_time": "2023-07-11T09:32:26",
"upload_time_iso_8601": "2023-07-11T09:32:26.812030Z",
"url": "https://files.pythonhosted.org/packages/30/7e/9bfb94cc068607b289022891fdd309e15c9b0e62533568bc9073bd06269c/fastapi-config-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-11 09:32:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "amisadmin",
"github_project": "fastapi_config",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fastapi-config"
}