bugfix
This commit is contained in:
parent
175a497493
commit
1028c20c08
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
from traceback import print_exc
|
||||
|
||||
import asyncio
|
||||
@ -238,7 +239,7 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
filepath = self.url2file(str(request.url))
|
||||
print('filepath=',filepath,str(request.url))
|
||||
if filepath and self.isHtml(filepath):
|
||||
return await html_handle(request, filepath)
|
||||
return await self.html_handle(request, filepath)
|
||||
|
||||
print(f'path={path} handler by StaticResource..')
|
||||
if self.isFolder(path):
|
||||
@ -247,7 +248,7 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
raise HTTPNotFound
|
||||
return await super()._handle(request)
|
||||
|
||||
def html_handle(self,request,filepath):
|
||||
async def html_handle(self,request,filepath):
|
||||
with codecs.open(filepath,'r', 'utf-8') as f:
|
||||
b = f.read()
|
||||
b = unicode_escape(b)
|
||||
@ -265,7 +266,7 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
b = f.read()
|
||||
if b.startswith('<html>'):
|
||||
return True
|
||||
if b.stratswith('<!doctype html>'):
|
||||
if b.startswith('<!doctype html>'):
|
||||
return True
|
||||
except Exception as e:
|
||||
print_exc()
|
||||
|
@ -51,14 +51,12 @@ class Url2File:
|
||||
if url[-1] == '/':
|
||||
url = url[:-1]
|
||||
|
||||
print('url2file.py:self.starts=',self.starts)
|
||||
if url.startswith(self.starts):
|
||||
f = self.path + url[len(self.starts):]
|
||||
paths = url.split('/')[3:]
|
||||
f = os.path.join(self.path,*paths)
|
||||
real_path = os.path.abspath(f)
|
||||
|
||||
if os.path.isdir(real_path):
|
||||
for f in self.indexes:
|
||||
p = os.path.join(real_path,'f)
|
||||
for idx in self.indexes:
|
||||
p = os.path.join(real_path,idx)
|
||||
if os.path.isfile(p):
|
||||
return p
|
||||
|
||||
@ -66,7 +64,6 @@ class Url2File:
|
||||
return real_path
|
||||
|
||||
if not self.inherit:
|
||||
print('url2file.py:real_path=',real_path)
|
||||
return None
|
||||
items = url.split('/')
|
||||
if len(items) > 2:
|
||||
|
Loading…
Reference in New Issue
Block a user