From 1834fde7d5e13da7504de5c62d9b084b4c767597 Mon Sep 17 00:00:00 2001 From: yu moqing Date: Thu, 24 Dec 2020 18:55:17 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 11 ++++++++--- setup.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 4bc2cb9..1382d0a 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -230,7 +230,7 @@ class ProcessorResource(StaticResource,Url2File): if filepath and self.isHtml(filepath): return await self.html_handle(request, filepath) - if os.path.isdir(filepath): + if filepath and os.path.isdir(filepath): config = getConfig() if not config.website.allowListFolder: raise HTTPNotFound @@ -252,9 +252,11 @@ class ProcessorResource(StaticResource,Url2File): try: with codecs.open(fn,'r','utf-8') as f: b = f.read() - if b.startswith(''): + while b[0] in ['\n',' ','\t']: + b = b[1:] + if b.lower().startswith(''): return True - if b.startswith(''): + if b.lower().startswith(''): return True except Exception as e: return False @@ -285,6 +287,9 @@ class ProcessorResource(StaticResource,Url2File): if url.startswith('/'): return '%s%s' % (h,url) path = request.path + fn = self.url2file(str(request.url)) + if fn and os.path.isdir(fn): + path = '%s/oops' % path p = self.relatedurl(path,url) return '%s%s' % (h, p) diff --git a/setup.py b/setup.py index 3e0f566..2c3b1be 100755 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from setuptools import setup, find_packages # python setup.py bdist_egg generate a egg file # Release information about eway -version = "0.0.1" +version = "0.0.2" name = "ahserver" description = "ahserver" author = "yumoqing"