import json, urllib.request, ssl
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
UA={"User-Agent":"Mozilla/5.0","Content-Type":"application/json","Accept":"application/json"}
def req(method,url,body=None):
    data = json.dumps(body).encode() if body is not None else None
    r=urllib.request.Request(url,data=data,method=method,headers=UA)
    try:
        x=urllib.request.urlopen(r,context=ctx,timeout=25)
        return x.status, x.read().decode()
    except urllib.error.HTTPError as e:
        return e.code, e.read().decode()
    except Exception as e:
        return None, str(e)

H="https://www.fansky.net"
tests = [
 ("POST", H+"/api/v1/creator-dashboard/attachments/pre-signed-url", {"fingerprint":"test-file"}),
 ("POST", H+"/api/v1/creator-dashboard/attachments/pre-signed-url", {"downloadMethod":"s3","fingerprint":"test-file","regenerate":True}),
 ("POST", H+"/api/v1/admin-dashboard/attachments/pre-signed-url", {"fingerprint":"test-file"}),
 ("POST", H+"/api/v1/admin-dashboard/attachments/pre-signed-url", {}),
 ("POST", H+"/api/v1/creator/products/1/attachments/1/pre-signed-url", {"fingerprint":"test-file","downloadMethod":"s3"}),
 ("POST", H+"/api/v1/creator/products/1/attachments/1/pre-signed-url", {}),
 ("GET",  H+"/api/v1/creator-dashboard/attachments/pre-signed-url", None),
]
for m,u,b in tests:
    st, resp = req(m,u,b)
    print(f"[{m} {u.replace(H,'')}] {st} -> {resp[:400]}")
    print()
