From 175a49749398e308833728d2a03298b60a162314 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 18 Dec 2020 13:46:35 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 1 + ahserver/url2file.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index f4dd857..f8a4d35 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -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) diff --git a/ahserver/url2file.py b/ahserver/url2file.py index dfabf91..5576f96 100644 --- a/ahserver/url2file.py +++ b/ahserver/url2file.py @@ -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: