# Office365 — M365 Bypass Flask App (cPanel / WSGI deployment)

This project wraps `M365_Bypass_GUI_reconstructed.py` into a Flask web app with a JSON API and a simple web UI.

## Project structure

```
/home/aryakun/office365/
├── m365_bypass.py      # original bypass engine (copied module)
├── app.py              # Flask app (API + UI)
├── requirements.txt    # python deps
├── passenger_wsgi.py   # cPanel WSGI entry point
└── static/
    └── index.html      # web UI
```

## API endpoints

- `GET /api/health` — health check.
- `POST /api/bypass` — body JSON: `{ "email": "...", "password": "...", "app_id": "..." (optional) }`.
  - Starts async bypass job, returns `{ "ok": true, "job_id": "..." }`.
- `GET /api/status/<job_id>` — job status: `queued | running | completed | failed`, with `progress`, `logs[]`, and `result` (on completion).

## Local test

```bash
cd /home/aryakun/office365
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
flask run
```

Then:
- UI: `http://127.0.0.1:5000/`
- API: `POST http://127.0.0.1:5000/api/bypass` with JSON body; poll `GET /api/status/<job_id>`.

## cPanel upload / setup (WYSIWYG Python / Passenger)

1. Upload the project folder to the server, e.g. `/home/<user>/office365/`
   (must contain `passenger_wsgi.py`, `app.py`, `requirements.txt`, `m365_bypass.py`, `static/index.html`).
2. In cPanel → **Setup** → **Setup Python App**:
   - **Python version**: choose an available 3.x version (e.g. 3.11).
   - **Application mode**: Production.
   - **Application root**: `/home/<user>/office365`
   - **Application startup file**: `passenger_wsgi.py`
   - **Application URI**: `/office365` (or `/` if you want it at domain root).
   - **Requirements file**: `requirements.txt`
3. Click **Create Application** — cPanel creates a virtualenv and installs requirements automatically.
4. Restart the application: cPanel → **Setup** → **Setup Python App** → restart, or restart the Apache/nginx + Passenger service.
5. Open `https://<your-domain>/office365/` (or the URI you chose).

The Flask app is exposed through Passenger via `passenger_wsgi.py`:

```python
from app import app as application
```

Flask must be listed in `requirements.txt`; the bypass engine dependencies used at runtime are `requests` and `msal` (Playwright is optional and only needed for the browser bridge fallback).
