This commit is contained in:
yumoqing 2023-12-18 19:09:47 +08:00
parent ab9e41bb69
commit ab900123aa
2 changed files with 14 additions and 1 deletions

View File

@ -52,6 +52,7 @@ from .restful import DBCrud
from .dbadmin import DBAdmin from .dbadmin import DBAdmin
from .filedownload import file_download, path_decode from .filedownload import file_download, path_decode
from .utils import unicode_escape from .utils import unicode_escape
from .filetest import current_fileno
def getHeaderLang(request): def getHeaderLang(request):
al = request.headers.get('Accept-Language') al = request.headers.get('Accept-Language')
@ -228,6 +229,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
async def get_user(): async def get_user():
return await auth.get_auth(request) return await auth.get_auth(request)
f_cnt1 = current_fileno()
self.y_env.i18n = serveri18n self.y_env.i18n = serveri18n
self.y_env.file_realpath = file_realpath self.y_env.file_realpath = file_realpath
self.y_env.redirect = redirect self.y_env.redirect = redirect
@ -253,6 +255,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
request['request_filename'] = self.request_filename request['request_filename'] = self.request_filename
path = request.path path = request.path
config = getConfig() config = getConfig()
f_cnt2 = current_fileno()
request['port'] = config.website.port request['port'] = config.website.port
if config.website.dbadm and path.startswith(config.website.dbadm): if config.website.dbadm and path.startswith(config.website.dbadm):
pp = path.split('/')[2:] pp = path.split('/')[2:]
@ -264,6 +267,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
action = pp[2] action = pp[2]
adm = DBAdmin(request,dbname,tablename,action) adm = DBAdmin(request,dbname,tablename,action)
return await adm.render() return await adm.render()
f_cnt3 = current_fileno()
if config.website.dbrest and path.startswith(config.website.dbrest): if config.website.dbrest and path.startswith(config.website.dbrest):
pp = path.split('/')[2:] pp = path.split('/')[2:]
if len(pp)<2: if len(pp)<2:
@ -276,6 +280,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
id = pp[2] id = pp[2]
crud = DBCrud(request,dbname,tablename,id=id) crud = DBCrud(request,dbname,tablename,id=id)
return await crud.dispatch() return await crud.dispatch()
f_cnt4 = current_fileno()
if config.website.download and path.startswith(config.website.download): if config.website.download and path.startswith(config.website.download):
pp = path.split('/')[2:] pp = path.split('/')[2:]
if len(pp)<1: if len(pp)<1:
@ -285,20 +290,27 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
path = path_decode(dp) path = path_decode(dp)
return await file_download(request, path) return await file_download(request, path)
f_cnt5 = current_fileno()
# processor = self.url2processor(request, str(request.url)) # processor = self.url2processor(request, str(request.url))
processor = self.url2processor(request, str(request.url), self.request_filename) processor = self.url2processor(request, str(request.url), self.request_filename)
if processor: if processor:
return await processor.handle(request) ret = await processor.handle(request)
f_cnt6 = current_fileno()
print(f'{f_cnt1=}, {f_cnt2=}, {f_cnt3=}, {f_cnt4=}, {f_cnt5=}, {f_cnt6=}')
return ret
f_cnt6 = current_fileno()
if self.request_filename and await self.isHtml(self.request_filename): if self.request_filename and await self.isHtml(self.request_filename):
return await self.html_handle(request, self.request_filename) return await self.html_handle(request, self.request_filename)
f_cnt7 = current_fileno()
if self.request_filename and os.path.isdir(self.request_filename): if self.request_filename and os.path.isdir(self.request_filename):
config = getConfig() config = getConfig()
if not config.website.allowListFolder: if not config.website.allowListFolder:
self.error('%s:not found' % str(request.url)) self.error('%s:not found' % str(request.url))
raise HTTPNotFound raise HTTPNotFound
# print(f'{self.request_filename=}, {str(request.url)=}') # print(f'{self.request_filename=}, {str(request.url)=}')
f_cnt8 = current_fileno()
return await super()._handle(request) return await super()._handle(request)
def gethost(self, request): def gethost(self, request):

View File

@ -114,6 +114,7 @@ class WebsocketProcessor(PythonScriptProcessor):
# print('msg.data=', msg.data) # print('msg.data=', msg.data)
elif msg.type == aiohttp.WSMsgType.ERROR: elif msg.type == aiohttp.WSMsgType.ERROR:
# print('ws connection closed with exception %s' % ws.exception()) # print('ws connection closed with exception %s' % ws.exception())
pass
else: else:
print('datatype error', msg.type) print('datatype error', msg.type)
# print('5----------------------------------') # print('5----------------------------------')