This commit is contained in:
yumoqing 2023-08-24 22:58:38 -04:00
parent 1feb656eb1
commit e9499a857f
3 changed files with 6 additions and 0 deletions

View File

@ -183,6 +183,7 @@ class PythonScriptProcessor(BaseProcessor):
lenv = self.run_ns lenv = self.run_ns
del lenv['request'] del lenv['request']
txt = self.loadScript(self.real_path) txt = self.loadScript(self.real_path)
# print(self.real_path, "#########", txt)
exec(txt,lenv,lenv) exec(txt,lenv,lenv)
func = lenv['myfunc'] func = lenv['myfunc']
return await func(request,**lenv) return await func(request,**lenv)

View File

@ -308,6 +308,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
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)=}')
return await super()._handle(request) return await super()._handle(request)
def gethost(self, request): def gethost(self, request):

View File

@ -30,6 +30,7 @@ class Url2File:
paths = paths[3:] paths = paths[3:]
f = os.path.join(self.path,*paths) f = os.path.join(self.path,*paths)
real_path = os.path.abspath(f) real_path = os.path.abspath(f)
# print(f'{real_path=}, {url=}, {f=}')
return real_path return real_path
def url2file(self, url: str) -> str: def url2file(self, url: str) -> str:
@ -40,6 +41,7 @@ class Url2File:
for idx in self.indexes: for idx in self.indexes:
p = os.path.join(real_path,idx) p = os.path.join(real_path,idx)
if os.path.isfile(p): if os.path.isfile(p):
# print(f'{url=}, {real_path=}, {idx=}, {p=}')
return p return p
if os.path.isfile(real_path): if os.path.isfile(real_path):
@ -56,7 +58,9 @@ class Url2File:
items = url.split('/') items = url.split('/')
if len(items) > 2: if len(items) > 2:
del items[-2] del items[-2]
oldurl = url
url = '/'.join(items) url = '/'.join(items)
# print(f'{oldurl=}, {url=}')
return self.url2file(url) return self.url2file(url)
print(f'url2file() return None finally, {items:}, {url=}, {ourl=}, {self.path=}') print(f'url2file() return None finally, {items:}, {url=}, {ourl=}, {self.path=}')
return None return None