AMOS common api
Project description
amos api
主要用于定义离线分析中的 API 规范以及通用的 Response 等
快速开始
from fastapi import (FastAPI, Body)
from amos_api import (BaseResponse, HttpCode)
from starlette.responses import RedirectResponse
async def document():
# return RedirectResponse(url="/docs")
return RedirectResponse(url="/redoc")
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._422常用于参数错误HttpCode._500服务器错误,内部错误HttpCode._522服务器错误,内部错误
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.5.tar.gz
(2.6 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.5.tar.gz.
File metadata
- Download URL: amos_api-1.0.5.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1e326f6bca122330800a3f7f5d26f2d3995b5401c1fcf427ad1c14467a851f
|
|
| MD5 |
9ff322f372c09724e69929bfd4f38c20
|
|
| BLAKE2b-256 |
e48a7775357cfe0e86e15a79cb9132918f3cd8b7468ef366caf8efe083b20691
|
File details
Details for the file amos_api-1.0.5-py3-none-any.whl.
File metadata
- Download URL: amos_api-1.0.5-py3-none-any.whl
- Upload date:
- Size: 2.6 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 |
14ab2890e52d680d4b9eca5fdb5107f81cf41762bdcc98c3b4d569adfb8232b6
|
|
| MD5 |
fd7dc04583ae52e5b2448f01d5884543
|
|
| BLAKE2b-256 |
2bfd646b5939b2c4af6abda27a4785e300cb3867f63ce60f44b912e9e81018d7
|