38086-vm/config/wsgi.py
2026-02-13 05:38:22 +00:00

41 lines
991 B
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
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
# Patch for WeasyPrint libraries
try:
import ctypes
import ctypes.util
for lib in ['gobject-2.0', 'pango-1.0', 'cairo', 'harfbuzz', 'fontconfig']:
path = ctypes.util.find_library(lib)
if path:
try:
ctypes.CDLL(path)
except OSError:
pass
except Exception:
pass
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()