bugfix
This commit is contained in:
parent
26b01e96ac
commit
2c57d614d3
@ -85,7 +85,7 @@ class BaseProcessor:
|
||||
elif type(self.content) == type([]):
|
||||
self.content = json.dumps(self.content,
|
||||
indent=4)
|
||||
self.content = unicode_escape(self.content)
|
||||
# self.content = unicode_escape(self.content)
|
||||
self.setheaders()
|
||||
return Response(text=self.content,headers=self.headers)
|
||||
|
||||
@ -94,7 +94,8 @@ class BaseProcessor:
|
||||
self.content=''
|
||||
|
||||
def setheaders(self):
|
||||
self.headers['Content-Length'] = str(len(self.content))
|
||||
pass
|
||||
# self.headers['Content-Length'] = str(len(self.content))
|
||||
|
||||
class TemplateProcessor(BaseProcessor):
|
||||
@classmethod
|
||||
@ -172,7 +173,7 @@ class MarkdownProcessor(BaseProcessor):
|
||||
|
||||
async def datahandle(self,request:Request):
|
||||
data = ''
|
||||
with codecs.open(self.real_path,'r','utf-8') as f:
|
||||
with codecs.open(self.real_path,'rb','utf-8') as f:
|
||||
data = f.read()
|
||||
self.content = self.urlreplace(data, request)
|
||||
|
||||
|
@ -242,15 +242,16 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
return await super()._handle(request)
|
||||
|
||||
async def html_handle(self,request,filepath):
|
||||
with codecs.open(filepath,'r', 'utf-8') as f:
|
||||
with open(filepath,'rb') as f:
|
||||
b = f.read()
|
||||
b = unicode_escape(b)
|
||||
utxt = b.decode('unicode_escape')
|
||||
txt = b.decode('utf-8')
|
||||
headers = {
|
||||
'Content-Type': 'text/html; utf-8',
|
||||
'Accept-Ranges': 'bytes',
|
||||
'Content-Length': str(len(b))
|
||||
'Content-Length': str(len(utxt))
|
||||
}
|
||||
resp = Response(text=b,headers=headers)
|
||||
resp = Response(text=txt,headers=headers)
|
||||
return resp
|
||||
|
||||
def isHtml(self,fn):
|
||||
|
Loading…
Reference in New Issue
Block a user