"""
passenger_wsgi.py
=================

PURPOSE
-------
This is the file cPanel's "Setup Python App" (which uses Phusion Passenger)
looks for to start your web application. Passenger imports this file and
expects to find a variable named EXACTLY `application` that is a WSGI app.

WHAT THIS FILE DOES
-------------------
It does almost nothing on its own — it just imports the Flask `app` object we
built in app.py and exposes it under the name Passenger requires.

  app.py defines:        app  (a Flask instance, which is a WSGI application)
  Passenger wants:       application

So we map one to the other.

WHY THE sys.path LINE?
----------------------
Depending on how cPanel launches Passenger, the current working directory may
not be this project's folder, which can make `import app` fail. To be safe we
add this file's own directory to Python's import search path first.
"""

import os
import sys

# Absolute path to the folder this file lives in (your project root).
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))

# Put the project folder at the FRONT of the import path so `import app`,
# `import config`, etc. resolve to our files.
if PROJECT_ROOT not in sys.path:
    sys.path.insert(0, PROJECT_ROOT)

# Import the Flask application object from app.py ...
from app import app as application  # noqa: E402  (import must follow sys.path setup)

# ... now `application` is the name Passenger will serve. Nothing else needed.
