feat: 增加跨平台打包脚本
This commit is contained in:
+12
-1
@@ -2,13 +2,24 @@
|
||||
配置管理模块
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
def _resolve_base_dir() -> Path:
|
||||
env_base_dir = os.environ.get("CAPAREPORT_BASE_DIR")
|
||||
if env_base_dir:
|
||||
return Path(env_base_dir).expanduser().resolve()
|
||||
if getattr(sys, "frozen", False):
|
||||
return Path(sys.executable).resolve().parent
|
||||
return Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
BASE_DIR = _resolve_base_dir()
|
||||
CACHE_DIR = BASE_DIR / "cache"
|
||||
CONFIG_FILE = BASE_DIR / "Configure.json"
|
||||
SQL_SCRIPT = BASE_DIR / "ReportScript.sql"
|
||||
|
||||
+17
-4
@@ -1,4 +1,5 @@
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, HTTPException, Request
|
||||
@@ -117,8 +118,20 @@ def _safe_file(root: Path, path: str) -> Path | None:
|
||||
app = create_app()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description="CapacityReport server")
|
||||
parser.add_argument("--host", default=APP_HOST, help="Host to bind")
|
||||
parser.add_argument("--port", default=APP_PORT, type=int, help="Port to bind")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def run_server(host: str = APP_HOST, port: int = APP_PORT) -> None:
|
||||
print(f"CapacityReport v{APP_VERSION}")
|
||||
print(f"配置更新时间: {state.current_config().update}")
|
||||
print(f"前端地址: http://localhost:{APP_PORT}")
|
||||
uvicorn.run(app, host=APP_HOST, port=APP_PORT, reload=False)
|
||||
print(f"Config update: {state.current_config().update}")
|
||||
print(f"Frontend: http://localhost:{port}")
|
||||
uvicorn.run(app, host=host, port=port, reload=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
run_server(args.host, args.port)
|
||||
|
||||
Reference in New Issue
Block a user