fastapi-basic 0.0.7__tar.gz → 0.0.8__tar.gz
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.
Potentially problematic release.
This version of fastapi-basic might be problematic. Click here for more details.
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/PKG-INFO +3 -2
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic/base_factory.py +27 -14
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic.egg-info/PKG-INFO +3 -2
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic.egg-info/requires.txt +1 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/setup.py +1 -1
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/README.md +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic/__init__.py +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic/base_config.py +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic/const.py +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic/utils.py +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic.egg-info/SOURCES.txt +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic.egg-info/dependency_links.txt +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/fastapi_basic.egg-info/top_level.txt +0 -0
- {fastapi_basic-0.0.7 → fastapi_basic-0.0.8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi_basic
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A short description of your module
|
|
5
5
|
Home-page: https://github.com/szx21023/fastapi-base
|
|
6
6
|
Author: szx21023
|
|
@@ -22,6 +22,7 @@ Requires-Dist: idna==3.10
|
|
|
22
22
|
Requires-Dist: pydantic==2.11.3
|
|
23
23
|
Requires-Dist: pydantic_core==2.33.1
|
|
24
24
|
Requires-Dist: python-dotenv==1.1.0
|
|
25
|
+
Requires-Dist: python-multipart==0.0.20
|
|
25
26
|
Requires-Dist: requests==2.32.3
|
|
26
27
|
Requires-Dist: sniffio==1.3.1
|
|
27
28
|
Requires-Dist: starlette==0.46.1
|
|
@@ -2,7 +2,8 @@ from abc import ABCMeta, abstractmethod
|
|
|
2
2
|
from functools import lru_cache
|
|
3
3
|
import os, dotenv
|
|
4
4
|
|
|
5
|
-
from fastapi import FastAPI
|
|
5
|
+
from fastapi import FastAPI, Request
|
|
6
|
+
from starlette.concurrency import iterate_in_threadpool
|
|
6
7
|
import logging
|
|
7
8
|
|
|
8
9
|
from .const import LOG_DEFAULT_LOGGER_NAME, LOG_FMT
|
|
@@ -16,19 +17,6 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
16
17
|
Each factory should define what config it wants.
|
|
17
18
|
"""
|
|
18
19
|
|
|
19
|
-
def create_app(self):
|
|
20
|
-
"""
|
|
21
|
-
Create an application instance.
|
|
22
|
-
"""
|
|
23
|
-
self.__load_local_config()
|
|
24
|
-
app_config = self.get_app_config()
|
|
25
|
-
app = FastAPI(docs_url=app_config.get('DOCS_URL'), redoc_url=app_config.get('REDOC_URL'), openapi_url=app_config.get('OPENAPI_URL'))
|
|
26
|
-
app.state.config = app_config
|
|
27
|
-
|
|
28
|
-
self.__setup_main_logger(app, logger_name=app.state.config.get('LOGGER_NAME', LOG_DEFAULT_LOGGER_NAME), level=logging.DEBUG)
|
|
29
|
-
|
|
30
|
-
return app
|
|
31
|
-
|
|
32
20
|
def __load_local_config(self):
|
|
33
21
|
dotenv.load_dotenv(dotenv_path='.env', override=True)
|
|
34
22
|
update_dict_with_cast(self.get_app_config(), os.environ)
|
|
@@ -45,3 +33,28 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
45
33
|
stream_handler.setFormatter(logging.Formatter(LOG_FMT))
|
|
46
34
|
logger.addHandler(stream_handler)
|
|
47
35
|
return logger
|
|
36
|
+
|
|
37
|
+
def create_app(self):
|
|
38
|
+
"""
|
|
39
|
+
Create an application instance.
|
|
40
|
+
"""
|
|
41
|
+
self.__load_local_config()
|
|
42
|
+
app_config = self.get_app_config()
|
|
43
|
+
app = FastAPI(docs_url=app_config.get('DOCS_URL'), redoc_url=app_config.get('REDOC_URL'), openapi_url=app_config.get('OPENAPI_URL'))
|
|
44
|
+
app.state.config = app_config
|
|
45
|
+
|
|
46
|
+
self.__setup_main_logger(app, logger_name=app.state.config.get('LOGGER_NAME', LOG_DEFAULT_LOGGER_NAME), level=logging.DEBUG)
|
|
47
|
+
|
|
48
|
+
@app.middleware("http")
|
|
49
|
+
async def handle_request_headers(request: Request, call_next):
|
|
50
|
+
body = await request.body()
|
|
51
|
+
form = await request.form()
|
|
52
|
+
app.logger.info(f"request.url: {request.url}, method: {request.method}, headers: {request.headers}, body: {body}, form: {form}")
|
|
53
|
+
response = await call_next(request)
|
|
54
|
+
response_body = [section async for section in response.body_iterator]
|
|
55
|
+
response.body_iterator = iterate_in_threadpool(iter(response_body))
|
|
56
|
+
if response_body:
|
|
57
|
+
app.logger.info(f"response_body: {response_body[0].decode()}")
|
|
58
|
+
return response
|
|
59
|
+
|
|
60
|
+
return app
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi_basic
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
4
4
|
Summary: A short description of your module
|
|
5
5
|
Home-page: https://github.com/szx21023/fastapi-base
|
|
6
6
|
Author: szx21023
|
|
@@ -22,6 +22,7 @@ Requires-Dist: idna==3.10
|
|
|
22
22
|
Requires-Dist: pydantic==2.11.3
|
|
23
23
|
Requires-Dist: pydantic_core==2.33.1
|
|
24
24
|
Requires-Dist: python-dotenv==1.1.0
|
|
25
|
+
Requires-Dist: python-multipart==0.0.20
|
|
25
26
|
Requires-Dist: requests==2.32.3
|
|
26
27
|
Requires-Dist: sniffio==1.3.1
|
|
27
28
|
Requires-Dist: starlette==0.46.1
|
|
@@ -5,7 +5,7 @@ with open('requirements.txt', 'r') as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name='fastapi_basic', # 模組名稱
|
|
8
|
-
version='0.0.
|
|
8
|
+
version='0.0.8', # 版號版號
|
|
9
9
|
description='A short description of your module', # 模塊描述
|
|
10
10
|
long_description=open('README.md').read(), # 詳細描述,通常是 README 文件的内容
|
|
11
11
|
long_description_content_type='text/markdown', # markdown 格式
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|