import os
import sys
from tracemalloc import start

# Application root is the current directory
app_root = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, app_root)

# Set Django settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

application = get_wsgi_application()

# Serve static files
static_root = os.path.join(app_root, 'staticfiles')
if os.path.exists(static_root):
    application = WhiteNoise(application, root=static_root)

# Serve media files
media_root = os.path.join(app_root, 'media')
if os.path.exists(media_root):
    application.add_files(media_root, prefix='media/')
    
