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
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
amos_api-1.0.4.tar.gz
(2.5 kB
view details)
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76fa0e95d93c5f886f24335fa3b2bb9964ac54db287db980be6a4b557bbf59d9
|
|
| MD5 |
dd560f06875f244e340d937451e8db97
|
|
| BLAKE2b-256 |
2198d29162b18f1809df061ac87e300b474fe9cef19a6b8acef9644cc7975c2c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8b27226ddb635e92e8e4385107d789a09c832dc90821b90194b57e963bb1e08
|
|
| MD5 |
a6c9ac47ab6ddc438b2fdb0c7e0451ca
|
|
| BLAKE2b-256 |
99c44b906f65d4a35e5ad75fc00a6cfa6274401b3a4fa814c4423cb8a521d449
|