Files
jiedian/panel/init_db.py
T
dekun bccf6cfdce feat: add web admin panel for node management
Add Flask panel with login, add/delete nodes, and share link copy.
Generate sing-box config from SQLite; add uninstall script and clean install flow.
Panel served at https://DOMAIN:8444 via nginx.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 09:10:19 +08:00

31 lines
774 B
Python

#!/usr/bin/env python3
"""初始化 SQLite 数据库与默认管理员。"""
from __future__ import annotations
import os
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "panel"))
os.environ.setdefault("JIEDIAN_ROOT", str(ROOT))
from db import init_db # noqa: E402
def load_env() -> dict[str, str]:
env: dict[str, str] = {}
for line in (ROOT / ".env").read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, _, value = line.partition("=")
env[key.strip()] = value.strip()
return env
if __name__ == "__main__":
init_db(load_env())
print("数据库初始化完成")