v2
This commit is contained in:
1 parent
0efaae1715
commit
c1a2a8cc30
13 files changed
+180
-137
No files matched your search
+7
-7
@@ -18,9 +18,9 @@ REPOSITORY = Path(os.environ.get("REPOSITORY_ROOT", "/srv/repository"))
|
||||
WEB = Path(__file__).resolve().parent / "web"
|
||||
PORT = int(os.environ.get("DASHBOARD_PORT", "8000"))
|
||||
CACHE_SECONDS = max(1, int(os.environ.get("DASHBOARD_CACHE_SECONDS", "15")))
|
||||
REPOSITORY_URL = os.environ.get("REPOSITORY_URL", "http://localhost:18765").rstrip("/")
|
||||
SITES = ("linux", "suse")
|
||||
META_PATHS = {"linux": Path("LINUX-BUILD-INFO.txt"), "suse": Path("SUSE-BUILD-INFO.txt")}
|
||||
REPOSITORY_URL = os.environ.get("REPOSITORY_URL", "http://localhost:18965").rstrip("/")
|
||||
SITES = ("debian", "rhel", "suse")
|
||||
META_PATHS = {"debian": Path("DEBIAN-BUILD-INFO.txt"), "rhel": Path("RHEL-BUILD-INFO.txt"), "suse": Path("SUSE-BUILD-INFO.txt")}
|
||||
DEB_FILENAME = re.compile(r"^(?P<name>.+?)_(?P<version>[^_]+)_(?P<arch>[^_]+)\.deb$")
|
||||
RPM_FILENAME = re.compile(r"^(?P<name>.+)-(?P<version>\d[^-]*)-(?P<release>[^/]+)\.(?P<arch>x86_64|amd64|aarch64|noarch|arm64)\.rpm$")
|
||||
|
||||
@@ -88,8 +88,8 @@ def generate_catalog(repository: Path = REPOSITORY) -> dict[str, object]:
|
||||
packages: list[dict[str, object]] = []
|
||||
if current:
|
||||
scans = [
|
||||
("linux", "DEB", "deb", current / "apt" / "pool", "*.deb"),
|
||||
("linux", "RPM", "rpm", current / "rpm" / "x86_64", "*.rpm"),
|
||||
("debian", "DEB", "deb", current / "apt" / "pool", "*.deb"),
|
||||
("rhel", "RPM", "rpm", current / "rpm" / "x86_64", "*.rpm"),
|
||||
("suse", "RPM", "rpm", current / "suse" / "x86_64", "*.rpm"),
|
||||
]
|
||||
for channel, label, kind, directory, pattern in scans:
|
||||
@@ -161,9 +161,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.send_bytes(json.dumps(CACHE.get(), ensure_ascii=False, separators=(",", ":")).encode(), "application/json; charset=utf-8", "no-store")
|
||||
elif path in ("/", "/index.html"):
|
||||
self.send_bytes((WEB / "index.html").read_bytes(), "text/html; charset=utf-8", "no-store", True)
|
||||
elif path in ("/ui/style.css", "/ui/app.js", "/ui/favicon.svg"):
|
||||
elif path in ("/ui/style.css", "/ui/app.js"):
|
||||
name = path.rsplit("/", 1)[-1]
|
||||
mime = {"style.css": "text/css", "app.js": "application/javascript", "favicon.svg": "image/svg+xml"}[name]
|
||||
mime = {"style.css": "text/css", "app.js": "application/javascript"}[name]
|
||||
self.send_bytes((WEB / name).read_bytes(), f"{mime}; charset=utf-8", "public, max-age=600")
|
||||
else:
|
||||
self.send_error(HTTPStatus.NOT_FOUND)
|
||||
|
||||
Reference in new issue
Block a user