|
12 | 12 | from app.component.environment import auto_include_routers, env |
13 | 13 | from fastapi.staticfiles import StaticFiles |
14 | 14 |
|
| 15 | +# Import middleware to register BabelMiddleware |
| 16 | +import app.middleware # noqa: F401 |
| 17 | + |
| 18 | +# Import exception handlers to register them |
| 19 | +import app.exception.handler # noqa: F401 |
| 20 | + |
15 | 21 | # Only initialize traceroot if enabled |
16 | 22 | if traceroot.is_enabled(): |
17 | 23 | from traceroot.integrations.fastapi import connect_fastapi |
| 24 | + |
18 | 25 | connect_fastapi(api) |
19 | 26 |
|
20 | 27 | logger = traceroot.get_logger("server_main") |
21 | 28 |
|
22 | 29 | prefix = env("url_prefix", "") |
23 | 30 | auto_include_routers(api, prefix, "app/controller") |
24 | | -public_dir = os.environ.get("PUBLIC_DIR") or os.path.join(os.path.dirname(__file__), "app", "public") |
| 31 | +public_dir = os.environ.get("PUBLIC_DIR") or os.path.join( |
| 32 | + os.path.dirname(__file__), "app", "public" |
| 33 | +) |
25 | 34 | if not os.path.isdir(public_dir): |
26 | 35 | try: |
27 | 36 | os.makedirs(public_dir, exist_ok=True) |
28 | 37 | logger.warning(f"Public directory did not exist. Created: {public_dir}") |
29 | 38 | except Exception as e: |
30 | | - logger.error(f"Public directory missing and could not be created: {public_dir}. Error: {e}") |
| 39 | + logger.error( |
| 40 | + f"Public directory missing and could not be created: {public_dir}. Error: {e}" |
| 41 | + ) |
31 | 42 | public_dir = None |
32 | 43 |
|
33 | 44 | if public_dir and os.path.isdir(public_dir): |
|
0 commit comments