# Publishing on Hostycare as a Subdomain (cPanel Python App)

This project is ready to deploy on **Hostycare** (cPanel **Setup Python App** / Phusion Passenger) on a subdomain such as `directory.yourdomain.com`.

## 1. Create the Subdomain in Hostycare cPanel
1. Log in to **Hostycare cPanel**.
2. Go to **Domains** (or **Subdomains**) -> **Create A New Domain**.
3. Enter your subdomain, e.g. `directory.yourdomain.com`, and leave the document root as suggested (e.g. `directory.yourdomain.com` or `public_html/directory`).
4. Ensure **AutoSSL / Let's Encrypt** is enabled for the subdomain so it loads over `https://`.

## 2. Create the Python App in cPanel
1. In cPanel, go to **Software** -> **Setup Python App**.
2. Click **Create Application** and configure:
   - **Python version:** `3.11` or `3.12` (any `3.10+` works)
   - **Application root:** `parish-directory` (outside `public_html`, e.g. `/home/<cpanel_user>/parish-directory`)
   - **Application URL:** select your subdomain (`directory.yourdomain.com`) and leave the path blank
   - **Application startup file:** `passenger_wsgi.py`
   - **Application Entry point:** `application`
3. Click **Create**.

## 3. Upload Application Files
Using cPanel **File Manager** (or SFTP/Git), upload the project files into your **Application root** (`/home/<cpanel_user>/parish-directory`):
- `app.py`
- `db.py`
- `passenger_wsgi.py`
- `requirements.txt`
- `static/` (entire folder, including `css/`, `js/`, `icons/`, `manifest.webmanifest`, `sw.js`)
- `templates/` (entire folder)
- Optional: upload `data/` if you want to copy existing submissions/photos; otherwise `data/` will be created automatically on first launch.

> **Do not upload** `__pycache__/`, `tests/`, or `.env.example` as `.env` without changing the password.

## 4. Install Dependencies
1. In **Setup Python App**, scroll to **Configuration files**, enter `requirements.txt`, click **Add**, then click **Run Pip Install**.
   *(Or open cPanel **Terminal**, activate the virtualenv command shown at the top of Setup Python App, `cd ~/parish-directory`, and run `pip install -r requirements.txt`.)*

## 5. Set Admin Password & Environment Variables
In **Setup Python App** -> **Environment variables** (or by creating a `.env` file in `~/parish-directory` based on `.env.example`):
- `PARISH_ADMIN_PASSWORD` = your committee portal password (change from default `parish2026`)
- `PARISH_SECRET_KEY` = any long random string
- `PARISH_SUBMISSION_DEADLINE` = optional deadline banner text (e.g., `31 December 2026`)

## 6. Restart & Verify
1. Click **Restart** in **Setup Python App**.
2. Open `https://directory.yourdomain.com`:
   - Public form loads directly in **App View** on mobile/tablet and **Classic View** (with **App View** toggle) on desktop.
   - Committee Portal is at `https://directory.yourdomain.com/admin`.

## Troubleshooting
- **500 Error:** Check `stderr.log` inside `~/parish-directory/` or cPanel **Errors**, and confirm `passenger_wsgi.py` and `requirements.txt` dependencies were installed in the app's virtual environment.
- **Upload permission error:** Ensure `~/parish-directory/data` and `~/parish-directory/data/uploads` have `755` permissions.
