修改环境配置文件
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from dotenv import dotenv_values
|
||||
import sqlparse
|
||||
import pymysql
|
||||
config = dotenv_values('.env')
|
||||
config = dotenv_values('.flaskenv')
|
||||
# MySql配置信息
|
||||
HOST = config.get('MYSQL_HOST') or '127.0.0.1'
|
||||
PORT = config.get('MYSQL_PORT') or 3306
|
||||
|
||||
@@ -8,6 +8,7 @@ from .init_error_views import init_error_views
|
||||
from .init_mail import init_mail
|
||||
from .init_apscheduler import init_scheduler
|
||||
from .init_upload import init_upload
|
||||
from .init_dotenv import init_dotenv
|
||||
|
||||
|
||||
def init_plugs(app: Flask) -> None:
|
||||
@@ -19,3 +20,4 @@ def init_plugs(app: Flask) -> None:
|
||||
init_mail(app)
|
||||
init_scheduler(app)
|
||||
init_upload(app)
|
||||
init_dotenv()
|
||||
|
||||
@@ -2,11 +2,13 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
root_path = os.path.abspath(os.path.dirname(__file__)).split('applications')[0]
|
||||
dot_env_path = os.path.join(root_path, '.env')
|
||||
# dot_env_path = os.path.join(root_path, '.env')
|
||||
flask_env_path = os.path.join(root_path, '.flaskenv')
|
||||
|
||||
if os.path.exists(dot_env_path):
|
||||
load_dotenv(dot_env_path)
|
||||
|
||||
# if os.path.exists(dot_env_path):
|
||||
# load_dotenv(dot_env_path)
|
||||
|
||||
def init_dotenv():
|
||||
if os.path.exists(flask_env_path):
|
||||
load_dotenv(flask_env_path)
|
||||
|
||||
Reference in New Issue
Block a user