forked from TheSmallHanCat/flow2api
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (28 loc) · 1.01 KB
/
Copy pathmain.py
File metadata and controls
36 lines (28 loc) · 1.01 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
"""Flow2API - Main Entry Point"""
import copy
from src.main import app
from src.core.logger import SensitiveAccessLogFilter
import uvicorn
def build_uvicorn_log_config():
"""Build Uvicorn logging config with secret redaction on HTTP and WebSocket logs."""
log_config = copy.deepcopy(uvicorn.config.LOGGING_CONFIG)
filter_name = "sensitive_query"
log_config.setdefault("filters", {})[filter_name] = {
"()": SensitiveAccessLogFilter,
}
for handler_name in ("access", "default"):
handler = log_config.setdefault("handlers", {}).setdefault(handler_name, {})
filters = list(handler.get("filters", []))
if filter_name not in filters:
filters.append(filter_name)
handler["filters"] = filters
return log_config
if __name__ == "__main__":
from src.core.config import config
uvicorn.run(
"src.main:app",
host=config.server_host,
port=config.server_port,
reload=False,
log_config=build_uvicorn_log_config(),
)