build: PyInstaller打包配置+启动器
This commit is contained in:
+11
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user