Spaces:
Running
Running
Download _ui_version_check.py from a3216/xtc-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/a3216/xtc-backend/resolve/main/_ui_version_check.py
- Command line
-
hf download hf://spaces/a3216/xtc-backend/_ui_version_check.py
-
curl -L -o _ui_version_check.py https://huggingface.co/spaces/a3216/xtc-backend/resolve/main/_ui_version_check.py
1.74 kB
| """验证后台页面:版本号已渲染、双钥匙块在、响应头 no-store。""" | |
| import os | |
| import tempfile | |
| _TMP = tempfile.mkdtemp(prefix="xtc_ui_") | |
| os.environ["no_proxy"] = os.environ["NO_PROXY"] = "localhost,127.0.0.1" | |
| os.environ["XTC_DB_PATH"] = os.path.join(_TMP, "t.db") | |
| os.environ["XTC_BUCKET_DIR"] = os.path.join(_TMP, "bucket") | |
| os.environ["XTC_DEV_MODE"] = "1" | |
| os.environ["XTC_JWT_SECRET"] = "s" * 40 | |
| os.environ["XTC_ADMIN_KEY"] = "ui-check-admin-key-123456" | |
| from fastapi.testclient import TestClient # noqa: E402 | |
| from app.main import app # noqa: E402 | |
| c = TestClient(app) | |
| r = c.get("/admin") | |
| print("status =", r.status_code) | |
| print("cache-control =", r.headers.get("cache-control")) | |
| print("pragma =", r.headers.get("pragma")) | |
| body = r.text | |
| checks = { | |
| "版本号 meta": 'name="xtc-admin-rev"' in body and "__UI_REV__" not in body, | |
| "双钥匙按钮(编辑)": "applyDualKeyPreset('ep')" in body, | |
| "双钥匙按钮(新增)": "applyDualKeyPreset('p')" in body, | |
| "编辑卡片请求头框": 'id="epExtraHeaders"' in body, | |
| "新增卡片请求头框": 'id="pExtraHeaders"' in body, | |
| "认证头名输入": 'id="epAuthHeader"' in body and 'id="pAuthHeader"' in body, | |
| "模型选择器(编辑)": 'id="epModelsPicker"' in body, | |
| "模型选择器(新增)": 'id="pModelsPicker"' in body, | |
| "厂商预设下拉": 'id="pPreset"' in body, | |
| "测试页批量测速": 'id="tBatchResult"' in body, | |
| "测试页厂商下拉": '<select id="tProvider"' in body, | |
| } | |
| for k, v in checks.items(): | |
| print((" [PASS] " if v else " [FAIL] ") + k) | |
| print("ui rev in page:", body.split('name="xtc-admin-rev" content="')[1].split('"')[0]) | |
| print("bytes =", len(body)) | |
| assert all(checks.values()), checks | |
| print("ALL PASS") | |