get status_code instead of ok

This commit is contained in:
2026-06-06 23:40:05 +02:00
parent 586223fe1a
commit 9a258cffb6
+7 -7
View File
@@ -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__