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.3.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.3.tar.gz.
File metadata
- Download URL: amos_api-1.0.3.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 |
140de63647f3f8aac4cfc99a4f21be389404bd6777e088414dce947b4f1c0f83
|
|
| MD5 |
69ca40a29cfbc232900e1f9acb3eb5ba
|
|
| BLAKE2b-256 |
781f0fa072d880dda0277889d895140f34f018c8741ef167f991d6de5bf0cb88
|
File details
Details for the file amos_api-1.0.3-py3-none-any.whl.
File metadata
- Download URL: amos_api-1.0.3-py3-none-any.whl
- Upload date:
- Size: 2.0 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 |
b460dddecad82a1e8955b199d69e65a69b3446367ef496ee9302ed14b1e12add
|
|
| MD5 |
e25e58512fa774d4d7ce7c66a3ca5e46
|
|
| BLAKE2b-256 |
191075edd230b4ec9b20d37ee0c461b20f77d573ca66fa15fb3421c19920b1e0
|