From 9c62b93c48c761d448afb90512dfcb1f445ae74b Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Tue, 28 May 2024 14:23:50 +0800 Subject: [PATCH] vault backup: 2024-05-28 14:23:50 --- 01. 輸出/把 Flask 包裝成 EXE 檔.md | 14 ++++++++++++++ ...Python is running as a script or as a frozen exe.md | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 01. 輸出/把 Flask 包裝成 EXE 檔.md create mode 100644 21. 資料收集/Programming/Python/Determine Python is running as a script or as a frozen exe.md diff --git a/01. 輸出/把 Flask 包裝成 EXE 檔.md b/01. 輸出/把 Flask 包裝成 EXE 檔.md new file mode 100644 index 0000000..64689ef --- /dev/null +++ b/01. 輸出/把 Flask 包裝成 EXE 檔.md @@ -0,0 +1,14 @@ +--- +tags: logitech, autoserver, kirby +aliases: +date: 2024-05-28 +time: 14:20:24 +description: +--- + +- 要加入 templates、static 與其他的靜態檔案 +- DB 位置不能用相對路徑,必須[[Determine Python is running as a script or as a frozen exe]],然後更新路徑 +- 要把 `flask db upgrade` 也變成 EXE 檔。 + + +# 參考來源 diff --git a/21. 資料收集/Programming/Python/Determine Python is running as a script or as a frozen exe.md b/21. 資料收集/Programming/Python/Determine Python is running as a script or as a frozen exe.md new file mode 100644 index 0000000..53e64e9 --- /dev/null +++ b/21. 資料收集/Programming/Python/Determine Python is running as a script or as a frozen exe.md @@ -0,0 +1,14 @@ +```python +import os +import sys + +config_name = 'myapp.cfg' + +# determine if application is a script file or frozen exe +if getattr(sys, 'frozen', False): + application_path = os.path.dirname(sys.executable) +elif __file__: + application_path = os.path.dirname(__file__) + +config_path = os.path.join(application_path, config_name) +``` \ No newline at end of file