ezKit 1.12.36__py3-none-any.whl → 1.12.37__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ezKit/fastapix.py +17 -0
- {ezkit-1.12.36.dist-info → ezkit-1.12.37.dist-info}/METADATA +1 -1
- {ezkit-1.12.36.dist-info → ezkit-1.12.37.dist-info}/RECORD +6 -6
- {ezkit-1.12.36.dist-info → ezkit-1.12.37.dist-info}/WHEEL +0 -0
- {ezkit-1.12.36.dist-info → ezkit-1.12.37.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.36.dist-info → ezkit-1.12.37.dist-info}/top_level.txt +0 -0
ezKit/fastapix.py
CHANGED
@@ -7,6 +7,7 @@ from typing import Any
|
|
7
7
|
|
8
8
|
from fastapi import FastAPI, Request
|
9
9
|
from fastapi.exceptions import RequestValidationError
|
10
|
+
from fastapi.middleware.cors import CORSMiddleware
|
10
11
|
from fastapi.responses import JSONResponse
|
11
12
|
from loguru import logger
|
12
13
|
from pydantic import ValidationError
|
@@ -32,6 +33,19 @@ logger.add(
|
|
32
33
|
)
|
33
34
|
|
34
35
|
|
36
|
+
# --------------------------------------------------------------------------------------------------
|
37
|
+
|
38
|
+
|
39
|
+
def CORS(app):
|
40
|
+
app.add_middleware(
|
41
|
+
CORSMiddleware,
|
42
|
+
allow_credentials=True,
|
43
|
+
allow_headers=["*"],
|
44
|
+
allow_methods=["*"],
|
45
|
+
allow_origins=["*"],
|
46
|
+
)
|
47
|
+
|
48
|
+
|
35
49
|
def Response(code: int = 200, data: Any = None, message: str | None = None, status_code: int = 200):
|
36
50
|
return JSONResponse(content={"code": code, "data": data, "message": message}, status_code=status_code)
|
37
51
|
|
@@ -62,6 +76,9 @@ def exceptions(app: FastAPI):
|
|
62
76
|
return Response(code=500, data=None, message="Server Internal Error")
|
63
77
|
|
64
78
|
|
79
|
+
# --------------------------------------------------------------------------------------------------
|
80
|
+
|
81
|
+
|
65
82
|
# 兼容 FastAPI/Uvicorn 的 logging(重要)
|
66
83
|
class InterceptHandler(logging.Handler):
|
67
84
|
"""Intercept Handler"""
|
@@ -6,7 +6,7 @@ ezKit/cipher.py,sha256=7jBarRH7ukSYzkz-Anl8B8JzluhnRz4CLHidPRRj_cg,2939
|
|
6
6
|
ezKit/database.py,sha256=WhHh-4L8uhqvDr7oIOPUk0jXLfLv0AVPAAKrOzhhxzQ,30239
|
7
7
|
ezKit/dockerhub.py,sha256=j-wQO-71BsOgExHZhYynuy2k_hCX3on-vg0TH7QCit4,1996
|
8
8
|
ezKit/errors.py,sha256=htTi7vKClHGHf2MX2G88PKr0zzUrFiUHEsrmfqj1Fx8,1425
|
9
|
-
ezKit/fastapix.py,sha256
|
9
|
+
ezKit/fastapix.py,sha256=-nz565ASKvp3nGs9J4wORTHxlhMozqCwv8zREWpmYtI,3382
|
10
10
|
ezKit/http.py,sha256=zhNxJF-x91UqGncXWxVXnhZVpFo_wmmpGnMXVT11y9E,1832
|
11
11
|
ezKit/markdown_to_html.template,sha256=21G2sSVGJn6aJvHd0NN4zY5YiDteKe4UtW36AzBwSdk,22274
|
12
12
|
ezKit/mongo.py,sha256=vsRCjJ2uWbNp-1bnGKICPohNYx25El8XnHp10o-lsM4,2397
|
@@ -17,8 +17,8 @@ ezKit/token.py,sha256=Ac-i9xfq4TqpGyfCzakjrh4NYzxHiN2sCQrMk1tzVi8,1716
|
|
17
17
|
ezKit/utils.py,sha256=U457ahFkxIXuB-qWvS3995xJs-LlkFIX5_ZWVgmL5cY,43130
|
18
18
|
ezKit/xftp.py,sha256=-XQXyhMqeigT63P6sXkSS7r4GROXyqqlkzKxITLWG-g,8278
|
19
19
|
ezKit/zabbix.py,sha256=PkMnfu7mcuotwwIIsHaC9FsNg-gap6hD1xvm0AwSL1Y,33777
|
20
|
-
ezkit-1.12.
|
21
|
-
ezkit-1.12.
|
22
|
-
ezkit-1.12.
|
23
|
-
ezkit-1.12.
|
24
|
-
ezkit-1.12.
|
20
|
+
ezkit-1.12.37.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
21
|
+
ezkit-1.12.37.dist-info/METADATA,sha256=Dc9xJPT4p0iqDczuhL7-qkBtf-4Cuk9RSFMUV3JEQSc,317
|
22
|
+
ezkit-1.12.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
ezkit-1.12.37.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
24
|
+
ezkit-1.12.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|