Created
July 15, 2024 07:42
-
-
Save nishio/d4e5d46a54a84bed680713a3d3af1404 to your computer and use it in GitHub Desktop.
private preview script for Talk to the City
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import urllib.parse | |
REPORT_DIR = "scatter/pipeline/outputs" | |
os.makedirs("build", exist_ok=True) | |
links = [] | |
for target in os.listdir(REPORT_DIR): | |
indir = f"{REPORT_DIR}/{target}/report" | |
# outdir sholud be URL safe | |
safe_target = urllib.parse.quote(target) | |
outdir = f"build/{safe_target}" | |
shutil.copytree(indir, outdir, dirs_exist_ok=True) | |
links.append(f"<li><a href='{safe_target}/index.html'>{target}</a></li>") | |
with open("build/index.html", "w") as f: | |
f.write( | |
f""" | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Private Preview</title> | |
</head> | |
<body> | |
<h1>Private Preview</h1> | |
<ul> | |
{''.join(links)} | |
</ul> | |
</body> | |
</html> | |
""" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment