This commit is contained in:
yumoqing 2020-12-18 13:46:35 +08:00
parent 401abe9763
commit 175a497493
2 changed files with 12 additions and 5 deletions

View File

@ -236,6 +236,7 @@ class ProcessorResource(StaticResource,Url2File):
return await processor.handle(request)
filepath = self.url2file(str(request.url))
print('filepath=',filepath,str(request.url))
if filepath and self.isHtml(filepath):
return await html_handle(request, filepath)

View File

@ -51,16 +51,22 @@ class Url2File:
if url[-1] == '/':
url = url[:-1]
if self.isFolder(url):
return self.defaultIndex(url)
print('url2file.py:self.starts=',self.starts)
if url.startswith(self.starts):
f = self.path + url[len(self.starts):]
real_path = os.path.abspath(f)
if os.path.isfile(real_path):
return f
if os.path.isdir(real_path):
for f in self.indexes:
p = os.path.join(real_path,'f)
if os.path.isfile(p):
return p
if os.path.isfile(real_path):
return real_path
if not self.inherit:
print('url2file.py:real_path=',real_path)
return None
items = url.split('/')
if len(items) > 2: