42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""
|
|
WSGI config for config project.
|
|
|
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import ctypes
|
|
import ctypes.util
|
|
|
|
try:
|
|
from dotenv import load_dotenv
|
|
env_path = Path(__file__).resolve().parent.parent.parent / '.env'
|
|
if env_path.exists():
|
|
load_dotenv(env_path)
|
|
except ImportError:
|
|
pass
|
|
|
|
# --- WeasyPrint Library Preloading ---
|
|
import ctypes
|
|
import ctypes.util
|
|
|
|
# Try to find and load libraries dynamically to help WeasyPrint on different platforms
|
|
libs_to_load = ['glib-2.0', 'gobject-2.0', 'fontconfig', 'cairo', 'pango-1.0', 'pangoft2-1.0']
|
|
for lib_name in libs_to_load:
|
|
try:
|
|
path = ctypes.util.find_library(lib_name)
|
|
if path:
|
|
ctypes.CDLL(path)
|
|
except Exception:
|
|
pass
|
|
# -------------------------------------
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
|
|
|
from django.core.wsgi import get_wsgi_application
|
|
|
|
application = get_wsgi_application() |