From 9a258cffb661d6830c5d34e1c3bf0657309267ca Mon Sep 17 00:00:00 2001 From: Fredrik Robertsen Date: Sat, 6 Jun 2026 23:40:05 +0200 Subject: [PATCH] get status_code instead of ok --- cursed.coco | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cursed.coco b/cursed.coco index de1f7df..37d58ac 100644 --- a/cursed.coco +++ b/cursed.coco @@ -19,14 +19,14 @@ def parse_path(path: str) -> str: def include_path(path: str) -> bool: return not any([x in path for x in EXCLUDES]) -def safe_get(path: str) -> bool: +def safe_get(path: str) -> str: try: - return requests.get(path).ok - except: - return False + return requests.get(path).status_code |> str + except Exception as e: + return str(e) if __name__ == "__main__": - output_file = "out/status.txt" + output_file = "out/status2.txt" print(f"writing to file `{output_file}`...") sys.stdout = open(output_file, "w") @@ -35,12 +35,12 @@ if __name__ == "__main__": print("----- TOM -----") tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list tom_oks = tom_paths |> map$(safe_get) |> list - zip(tom_oks, tom_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print + zip(tom_oks, tom_paths) |> map$(":\t".join) |> "\n".join |> print print("----- TEMMIE -----") tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list tem_oks = tem_paths |> map$(safe_get) |> list - zip(tem_oks, tem_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print + zip(tem_oks, tem_paths) |> map$(":\t".join) |> "\n".join |> print sys.stdout.close() sys.stdout = sys.__stdout__