fastapi_config


Namefastapi_config JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryFastAPI-Config is a visual dynamic configuration management extension based on FastAPI-Amis-Admin.
upload_time2023-12-13 06:54:02
maintainer
docs_urlNone
author
requires_python>=3.8
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.8",
    "maintainer_email": "",
    "keywords": "FastAPI-Amis-Admin,FastAPI-Config,Python-Config",
    "author": "",
    "author_email": "Atomi <1456417373@qq.com>",
    "download_url": "https://files.pythonhosted.org/packages/42/0e/af72a0c1011fabb6cb2cda00dd9b6e8fb99c2ab8349d117888efe5269fdd/fastapi-config-0.1.4.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.4",
    "project_urls": {
        "FastAPI-Amis-Admin": "https://github.com/amisadmin/fastapi_amis_admin",
        "Source": "https://github.com/amisadmin/fastapi_config"
    },
    "split_keywords": [
        "fastapi-amis-admin",
        "fastapi-config",
        "python-config"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "197ed64d37eef38194477d60a8b4576941dfeb8b0c0f6e43419888f84d1169f7",
                "md5": "4bf4098a37f7b2b7fc5cfebcbb272ae6",
                "sha256": "490e76c1ba395fc641081fddfd70420c1c54a9766da4a43eea9325e69c308500"
            },
            "downloads": -1,
            "filename": "fastapi_config-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4bf4098a37f7b2b7fc5cfebcbb272ae6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 37004,
            "upload_time": "2023-12-13T06:54:00",
            "upload_time_iso_8601": "2023-12-13T06:54:00.819475Z",
            "url": "https://files.pythonhosted.org/packages/19/7e/d64d37eef38194477d60a8b4576941dfeb8b0c0f6e43419888f84d1169f7/fastapi_config-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "420eaf72a0c1011fabb6cb2cda00dd9b6e8fb99c2ab8349d117888efe5269fdd",
                "md5": "439f3e75ac1ec27b10aec41fcd50a3bb",
                "sha256": "bd72e778a83dd10b36299ea591decc432343361a823d5ad61f901e64da5a4357"
            },
            "downloads": -1,
            "filename": "fastapi-config-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "439f3e75ac1ec27b10aec41fcd50a3bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28586,
            "upload_time": "2023-12-13T06:54:02",
            "upload_time_iso_8601": "2023-12-13T06:54:02.501028Z",
            "url": "https://files.pythonhosted.org/packages/42/0e/af72a0c1011fabb6cb2cda00dd9b6e8fb99c2ab8349d117888efe5269fdd/fastapi-config-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-13 06:54:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amisadmin",
    "github_project": "fastapi_amis_admin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastapi_config"
}
        
Elapsed time: 3.36901s