This commit is contained in:
yumoqing 2023-08-07 16:40:38 +08:00
parent 36c86520f0
commit 3f8fcc359d
2 changed files with 23 additions and 1 deletions

View File

@ -16,6 +16,7 @@ from .auth_api import AuthAPI
from .myTE import setupTemplateEngine
from .globalEnv import initEnv
from .filestorage import TmpFileRecord
from .loadplugins import load_plugins
class ConfiguredServer(AppLogger):
def __init__(self, auth_klass=AuthAPI, workdir=None):
@ -37,7 +38,7 @@ class ConfiguredServer(AppLogger):
if config.website.client_max_size:
client_max_size = config.website.client_max_size
print(f'{client_max_size=}')
load_plugins(self.workdir)
self.app = web.Application(client_max_size=client_max_size)
async def init_auth(self):

21
ahserver/loadplugins.py Normal file
View File

@ -0,0 +1,21 @@
import os
import sys
from appPublic.folderUtils import listFile
from appPublic.ExecFile import ExecFile
from ahserver.serverenv import ServerEnv
def load_plugins(p_dir):
ef = ExecFile()
pdir = os.path.join(p_dir, 'plugins')
if not os.path.isdir(pdir):
print('load_plugins:%s not exists' % pdir)
return
sys.path.append(pdir)
ef.set('sys',sys)
ef.set('ServerEnv', ServerEnv)
for m in listFile(pdir, subfixs='.py'):
if m.endswith('__init__.py'):
continue
__import__(m[:-3], locals(), globals())