build: PyInstaller打包配置+启动器

This commit is contained in:
2026-05-08 16:15:45 +08:00
parent c7ba14a81a
commit a5f4275e19
4 changed files with 104 additions and 1 deletions
+11 -1
View File
@@ -2,6 +2,7 @@
cDNA微阵列图像处理 - Web UI (Flask)
=====================================
启动:python web/app.py
打包:python build_exe.py
打开:http://localhost:5000
"""
@@ -19,7 +20,16 @@ from scipy import ndimage
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'src'))
app = Flask(__name__)
# PyInstaller 打包后资源路径
if getattr(sys, 'frozen', False):
bundle_dir = sys._MEIPASS
template_dir = os.path.join(bundle_dir, 'templates')
static_dir = os.path.join(bundle_dir, 'static')
else:
template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
app = Flask(__name__, template_folder=template_dir, static_folder=static_dir)
app.config['MAX_CONTENT_LENGTH'] = 50 * 1024 * 1024 # 50MB
UPLOAD_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'uploads')
os.makedirs(UPLOAD_DIR, exist_ok=True)