# Python

Uses the standard library `urllib.request` — no third-party dependencies required. Run each example as a standalone script.

## Examples

### Normal success

```python
import os, urllib.request

req = urllib.request.Request(
    f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
    data=b"Finished refactoring the auth middleware in rumilo. Session validation is cleaner now and all tests pass.",
)
req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
req.add_header("Title", "Refactored authentication middleware in rumilo")
req.add_header("Tags", "hammer_and_wrench")
urllib.request.urlopen(req)
```

### Success with a relevant click URL

```python
import os, urllib.request

req = urllib.request.Request(
    f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
    data=b"Bumped the kagi-ken AUR package to v0.4.2 and updated the checksums.",
)
req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
req.add_header("Title", "Updated AUR package for kagi-ken")
req.add_header("Tags", "package")
req.add_header("Click", "https://aur.archlinux.org/packages/kagi-ken")
urllib.request.urlopen(req)
```

### Something went wrong

```python
import os, urllib.request

req = urllib.request.Request(
    f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
    data=b"Ran into a full disk on the build server while compiling pi-mono. /var/log looks like it needs rotation. The build is blocked until there's space.",
)
req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
req.add_header("Title", "Build failed in pi-mono — disk full")
req.add_header("Tags", "rotating_light")
req.add_header("Priority", "4")
urllib.request.urlopen(req)
```

### Urgent failure

```python
import os, urllib.request

req = urllib.request.Request(
    f"https://ntfy.sh/{os.environ['NTFY_TOPIC_LLM']}",
    data=b"The primary Postgres instance stopped responding during a migration. Rolled back what we could, but the app is down.",
)
req.add_header("Authorization", f"Bearer {os.environ['NTFY_ACCESS_TOKEN']}")
req.add_header("Title", "Production database unreachable")
req.add_header("Tags", "sos")
req.add_header("Priority", "5")
urllib.request.urlopen(req)
```
