Initial commit
This commit is contained in:
40
config.py
Normal file
40
config.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# 載入環境變數
|
||||
load_dotenv()
|
||||
|
||||
class Config:
|
||||
"""應用程式配置類別"""
|
||||
|
||||
# 資料庫配置
|
||||
DB_HOST = os.getenv('DB_HOST', 'mysql.theaken.com')
|
||||
DB_PORT = int(os.getenv('DB_PORT', 33306))
|
||||
DB_NAME = os.getenv('DB_NAME', 'db_panjit_password')
|
||||
DB_USER = os.getenv('DB_USER', 'root')
|
||||
DB_PASSWORD = os.getenv('DB_PASSWORD', 'zh6161168')
|
||||
|
||||
# JWT 配置
|
||||
JWT_SECRET = os.getenv('JWT_SECRET', 'panjit666')
|
||||
|
||||
# API 配置
|
||||
API_HOST = os.getenv('API_HOST', '0.0.0.0')
|
||||
API_PORT = int(os.getenv('API_PORT', 5000))
|
||||
API_DEBUG = os.getenv('API_DEBUG', 'True').lower() == 'true'
|
||||
|
||||
# 應用程式配置
|
||||
APP_NAME = os.getenv('APP_NAME', 'Panjit Password Management API')
|
||||
APP_VERSION = os.getenv('APP_VERSION', '1.0.0')
|
||||
APP_DESCRIPTION = os.getenv('APP_DESCRIPTION', 'Panjit 密碼管理系統 API')
|
||||
|
||||
@classmethod
|
||||
def get_db_config(cls):
|
||||
"""取得資料庫配置字典"""
|
||||
return {
|
||||
'host': cls.DB_HOST,
|
||||
'port': cls.DB_PORT,
|
||||
'user': cls.DB_USER,
|
||||
'password': cls.DB_PASSWORD,
|
||||
'database': cls.DB_NAME,
|
||||
'charset': 'utf8mb4'
|
||||
}
|
Reference in New Issue
Block a user