#!/usr/bin/env python3
"""Enumerate all accessible endpoints in welcome app"""
import requests
import urllib3
urllib3.disable_warnings()

BASE = "https://localhost:5000"

# Common controller functions from welcome/default.py
endpoints = [
    "/welcome/default/index",
    "/welcome/default/user",
    "/welcome/default/user/login",
    "/welcome/default/user/register",
    "/welcome/default/download",
    "/welcome/default/call",
    "/welcome/default/data",
    "/welcome/default/wiki",
    # Try generic extensions
    "/welcome/default/index.json",
    "/welcome/default/index.xml",
    "/welcome/default/user.json",
]

print("[*] Testing welcome application endpoints...")
for endpoint in endpoints:
    try:
        r = requests.get(f"{BASE}{endpoint}", verify=False, allow_redirects=False, timeout=5)
        if r.status_code != 404:
            print(f"    {endpoint}: {r.status_code}")
            if r.status_code == 200 and len(r.text) < 500:
                print(f"      Content: {r.text[:200]}")
    except Exception as e:
        print(f"    {endpoint}: ERROR - {e}")
