import os
import sys

# Application root is the current directory
app_root = os.path.dirname(os.path.abspath(__file__))

# Add the taiwo_and_kehinde folder to Python path (where manage.py is located)
sys.path.insert(0, os.path.join(app_root, 'taiwo_and_kehinde'))

# 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, 'taiwo_and_kehinde', 'staticfiles')
if os.path.exists(static_root):
    application = WhiteNoise(application, root=static_root)

# Serve media files
media_root = os.path.join(app_root, 'taiwo_and_kehinde', 'media')
if os.path.exists(media_root):
    application.add_files(media_root, prefix='media/')