#!/usr/bin/env python3

import asyncio
import httpx
import sys

async def check_url(client, url):
    url = url.strip()
    if not url:
        return

    if not url.startswith(('http://', 'https://')):
        url = 'https://' + url

    try:
        response = await client.head(url, timeout=5.0, follow_redirects=True)

        if response.status_code == 200:
            print(f"[OK] {response.status_code} - {url}")
        else:
            print(f"[FAIL] {response.status_code} - {url}")

    except Exception as e:
        print(f"[ERROR] {type(e).__name__} - {url}")

async def main():
    urls = sys.stdin.readlines()

    if not urls:
        print("No url provided.")
        return

    async with httpx.AsyncClient() as client:
        tasks = [check_url(client, url) for url in urls]
        await asyncio.gather(*tasks)

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass
