| | import os, time, pathlib |
| |
|
| | os.environ.setdefault("TMPDIR", "/tmp/streamlit_tmp") |
| | tmpdir = pathlib.Path(os.environ["TMPDIR"]) |
| | tmpdir.mkdir(parents=True, exist_ok=True) |
| |
|
| | def prune_old_files(root: str, max_age_sec: int = 30 * 60): |
| | import time |
| | now = time.time() |
| | p = pathlib.Path(root) |
| | if not p.exists(): |
| | return |
| | for path in p.rglob("*"): |
| | try: |
| | if path.is_file() and (now - path.stat().st_mtime > max_age_sec): |
| | path.unlink(missing_ok=True) |
| | except Exception: |
| | pass |
| | for path in sorted(p.rglob("*"), reverse=True): |
| | try: |
| | if path.is_dir() and not any(path.iterdir()): |
| | path.rmdir() |
| | except Exception: |
| | pass |
| |
|
| | prune_old_files(tmpdir.as_posix(), max_age_sec=30 * 60) |
| | prune_old_files("/tmp", max_age_sec=60 * 60) |
| |
|
| | import streamlit as st |
| |
|
| | |
| | st.set_page_config(page_title="Leaderboard", layout="wide", page_icon="🏆") |
| |
|
| | main_page = st.Page("main.py", title="Описание") |
| | leaderboard_page = st.Page("Leaderboard.py", title="Лидерборд") |
| |
|
| | pg = st.navigation({"Main": [leaderboard_page, main_page]}) |
| | pg.run() |
| |
|