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) return await processor.handle(request)
filepath = self.url2file(str(request.url)) filepath = self.url2file(str(request.url))
print('filepath=',filepath,str(request.url))
if filepath and self.isHtml(filepath): if filepath and self.isHtml(filepath):
return await html_handle(request, filepath) return await html_handle(request, filepath)

View File

@ -51,16 +51,22 @@ class Url2File:
if url[-1] == '/': if url[-1] == '/':
url = url[:-1] url = url[:-1]
if self.isFolder(url): print('url2file.py:self.starts=',self.starts)
return self.defaultIndex(url)
if url.startswith(self.starts): if url.startswith(self.starts):
f = self.path + url[len(self.starts):] f = self.path + url[len(self.starts):]
real_path = os.path.abspath(f) 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: if not self.inherit:
print('url2file.py:real_path=',real_path)
return None return None
items = url.split('/') items = url.split('/')
if len(items) > 2: if len(items) > 2: