vault backup: 2024-05-28 14:23:50
This commit is contained in:
14
01. 輸出/把 Flask 包裝成 EXE 檔.md
Normal file
14
01. 輸出/把 Flask 包裝成 EXE 檔.md
Normal file
@@ -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 檔。
|
||||
|
||||
|
||||
# 參考來源
|
||||
@@ -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)
|
||||
```
|
||||
Reference in New Issue
Block a user