-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus_code.py
More file actions
40 lines (26 loc) · 1.03 KB
/
status_code.py
File metadata and controls
40 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from fastapi import APIRouter,Request,Response, status
from base import get_base_resp
status_router = APIRouter(prefix="/status", tags=["status"])
def get_status_return(codes,response:Response):
code_str = f"_{str(codes)}_"
for k,v in status.__dict__.items():
if code_str in k:
response.status_code = v
return
else:
return "invalid status code"
@status_router.get("/{codes}")
async def get_status(codes, response:Response):
return get_status_return(codes,response)
@status_router.delete("/{codes}")
async def delete_status(codes,response:Response):
return get_status_return(codes,response)
@status_router.put("/{codes}")
async def put_status(codes,response:Response):
return get_status_return(codes,response)
@status_router.post("/{codes}")
async def post_status(codes,response:Response):
return get_status_return(codes,response)
@status_router.patch("/{codes}")
async def patch_status(codes,response:Response):
return get_status_return(codes,response)