HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/hyperflight/apps/inxpress/README-Windows-IIS.md
# Flask + Jinja2 on IIS (Option 3)

This starter mirrors your Classic ASP pages while locking visuals. Numbers obey your rules: blank-if-zero for components and 2dp for totals via Jinja filters.

## 1) Quick dev run (Windows)
```bat
cd %~dp0
scripts\setup_venv.bat
scripts\run_dev.bat
```
Visit http://127.0.0.1:5000/health then http://127.0.0.1:5000/inxpress

## 2) Configure database
Copy `.env.example` to `.env` and fill in your MariaDB credentials (DB name default `circ_penn`).

## 3) Deploy on IIS
1. Install Python 3.11+ for **All Users**.
2. `pip install wfastcgi` (already in requirements).
3. In **IIS Manager**:
   - Create a new site/app pointing to this folder.
   - Ensure **FastCGI** feature is installed in Windows Roles.
   - Place **web.config** at the site root.
   - Edit the `scriptProcessor` in `web.config` to your actual `python.exe|...wfastcgi.py` paths.
   - Confirm that `/static/*` is served directly by IIS.
4. Set environment variables for the App Pool (optional) or use `.env` file.

### Notes
- `WSGI_HANDLER=app.app` means the Flask object named `app` in `app.py`.
- Keep your tuned CSS in `app/static/css/site.css` to preserve the exact look.
- Add more pages by copying your HTML into Jinja templates and using the provided filters.

## 4) Adding your existing CSS and templates
- Move your Bootstrap/custom CSS into `app/static/css/site.css` (or keep file names and link tags identical).
- For pixel-match, copy the exact table markup you already tuned.

## 5) Safety/consistency guardrails
- All number formatting goes via filters in `filters.py`:
  - `blank_if_zero` for Base/Fuel/Other/etc.
  - `fmt` for totals (always 2dp).
  - `nz`, `iif`, `fmt_date` also included.
- Keep queries parameterized as shown to avoid SQL injection.

## 6) Troubleshooting
- 500 on IIS? Temporarily enable detailed errors in IIS and check Event Viewer.
- Path to `python.exe`/`wfastcgi.py` wrong: 500 with handler errors → fix `web.config`.
- Static files not loading: confirm the Static Files rule and that the Files feature is installed.

## 7) Next steps
- Clone `inxpress` page first, verify pixel match, then proceed page-by-page.
- Add unit tests for filters to lock formatting semantics.
```

.env.example
DB_HOST=localhost
DB_USER=youruser
DB_PASS=yourpass
DB_NAME=circ_penn
```