Skip to main content

AMOS common api

Project description

amos api

主要用于定义离线分析中的 API 规范以及通用的 Response 等

快速开始

from fastapi import (FastAPI, Body)
from amos_api import (BaseResponse, HttpCode)

def mount_app_routes(app: FastAPI):
    app.get("/",
            response_model=BaseResponse,
            summary="swagger 文档")(document)
    # tag items
    app.post("/user",
             tags=["User"],
             summary="用户信息",
             )(userInfo)

async def userInfo(name: str=Body(..., description="用户名称", examples=["ray"])) -> BaseResponse:
    return BaseResponse(data={"seq":"1", "name": name,})

async def userList(name: str=Body(..., description="用户名称", examples=["ray"])) -> BaseResponse:
    try:
        dblist()
    except Exception as e:
        msg = f"未知错误{e}"
        return BaseResponse(code=HttpCode._500, msg=msg)
    return BaseResponse(data=[])
  • HttpCode._200 请求成功,正常 code 值,BaseResponse 如果不设置code时,默认值。
  • HttpCode._400 错误的请求,比如参数错误
  • HttpCode._403 禁止访问的资源
  • HttpCode._404 未找到
  • HttpCode._500 服务器错误,内部错误

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

amos_api-1.0.4.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

amos_api-1.0.4-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file amos_api-1.0.4.tar.gz.

File metadata

  • Download URL: amos_api-1.0.4.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.2

File hashes

Hashes for amos_api-1.0.4.tar.gz
Algorithm Hash digest
SHA256 76fa0e95d93c5f886f24335fa3b2bb9964ac54db287db980be6a4b557bbf59d9
MD5 dd560f06875f244e340d937451e8db97
BLAKE2b-256 2198d29162b18f1809df061ac87e300b474fe9cef19a6b8acef9644cc7975c2c

See more details on using hashes here.

File details

Details for the file amos_api-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: amos_api-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.2

File hashes

Hashes for amos_api-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b27226ddb635e92e8e4385107d789a09c832dc90821b90194b57e963bb1e08
MD5 a6c9ac47ab6ddc438b2fdb0c7e0451ca
BLAKE2b-256 99c44b906f65d4a35e5ad75fc00a6cfa6274401b3a4fa814c4423cb8a521d449

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