pull/781/head
dami 2 months ago
parent 369b53e2fd
commit 8069bf51ab
  1. 7
      web/admin/__init__.py
  2. 3
      web/config.py

@ -63,6 +63,7 @@ app.config['SESSION_USE_SIGNER'] = True
app.config['SESSION_KEY_PREFIX'] = 'MW_:' app.config['SESSION_KEY_PREFIX'] = 'MW_:'
app.config['SESSION_COOKIE_NAME'] = "MW_VER_1" app.config['SESSION_COOKIE_NAME'] = "MW_VER_1"
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31) app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 604800
# db的配置 # db的配置
# app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+config.SQLITE_PATH+"?timeout=20" # 使用 SQLite 数据库 # app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+config.SQLITE_PATH+"?timeout=20" # 使用 SQLite 数据库
@ -94,13 +95,12 @@ def sendAuthenticated():
@app.before_request @app.before_request
def requestCheck(): def requestCheck():
request.start_time = time.time()
admin_close = thisdb.getOption('admin_close') admin_close = thisdb.getOption('admin_close')
if admin_close == 'yes': if admin_close == 'yes':
if not request.path.startswith('/close'): if not request.path.startswith('/close'):
return redirect('/close') return redirect('/close')
config.APP_START_TIME=time.time()
# 自定义basic auth认证 # 自定义basic auth认证
if app.config['BASIC_AUTH_OPEN']: if app.config['BASIC_AUTH_OPEN']:
basic_auth = thisdb.getOptionByJson('basic_auth', default={'open':False}) basic_auth = thisdb.getOptionByJson('basic_auth', default={'open':False})
@ -129,8 +129,7 @@ def requestCheck():
def requestAfter(response): def requestAfter(response):
response.headers['soft'] = config.APP_NAME response.headers['soft'] = config.APP_NAME
response.headers['mw-version'] = config.APP_VERSION response.headers['mw-version'] = config.APP_VERSION
if mw.isDebugMode(): response.headers['X-Response-Time'] = round(time.time() - request.start_time, 4)
response.headers['mw-debug-cos'] = time.time() - config.APP_START_TIME
return response return response

@ -74,6 +74,3 @@ SQLITE_PATH = os.path.join(DATA_DIR, APP_SQLITE_NAME + '.db')
DEFAULT_SERVER = '0.0.0.0' DEFAULT_SERVER = '0.0.0.0'
DEFAULT_SERVER_PORT = 7201 DEFAULT_SERVER_PORT = 7201
# APP启动时间
APP_START_TIME=0

Loading…
Cancel
Save