import importlib.util
import os
import sys

# Fix ASCII encoding issue
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')

# Force UTF-8 environment
os.environ['PYTHONIOENCODING'] = 'utf-8'
os.environ['LANG'] = 'en_US.UTF-8'

sys.path.insert(0, os.path.dirname(__file__))

spec = importlib.util.spec_from_file_location("wsgi", "main.py")
wsgi = importlib.util.module_from_spec(spec)
spec.loader.exec_module(wsgi)

application = wsgi.app  # ← change this to match your main.py variable name