From a7adbf9f8f9189b81ab327ef521c2c7c0ec8a232 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 29 Nov 2019 11:35:33 +0800 Subject: [PATCH] checkifchange --- ahserver/baseProcessor.py | 12 ++++++------ ahserver/functionProcessor.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ahserver/baseProcessor.py b/ahserver/baseProcessor.py index f7f369d..08cc325 100644 --- a/ahserver/baseProcessor.py +++ b/ahserver/baseProcessor.py @@ -47,11 +47,10 @@ class BaseProcessor: self.path = path self.resource = resource self.retResponse = None - self.last_modified = os.path.getmtime(path) - self.content_length = os.path.getsize(path) + # self.last_modified = os.path.getmtime(path) + # self.content_length = os.path.getsize(path) self.headers = { - 'Content-Type': 'text/html', - 'Content-Length': str(self.content_length), + 'Content-Type': 'text/html; utf-8', 'Accept-Ranges': 'bytes' } self.content = '' @@ -93,9 +92,9 @@ class TemplateProcessor(BaseProcessor): async def datahandle(self,request): path = request.path ns = self.run_ns - te = g.tmpl_engine + te = self.run_ns.tmpl_engine + print('ns=',ns) self.content = te.render(path,**ns) - #self.content = await te.render_async(path,**ns) def setheaders(self): super(TemplateProcessor,self).setheaders() @@ -125,6 +124,7 @@ class PythonScriptProcessor(BaseProcessor): async def datahandle(self,request): g = ServerEnv() lenv = self.run_ns + del lenv['request'] if not g.get('dspy_cache',False): g.dspy_cache = ObjectCache() func = g.dspy_cache.get(self.path) diff --git a/ahserver/functionProcessor.py b/ahserver/functionProcessor.py index 238513e..ae8c90c 100644 --- a/ahserver/functionProcessor.py +++ b/ahserver/functionProcessor.py @@ -12,14 +12,14 @@ class FunctionProcessor(BaseProcessor): def __init__(self,path,resource, opts): self.config_opts = opts + BaseProcessor.__init__(self,path,resource) async def datahandle(self,request): - ns = self.config_opts.options.copy() + ns = self.config_opts.copy() ns.update(self.run_ns) - ns = DictObject(ns) - fname = self.config_opts.registerfunction + ns = DictObject(**ns) rf = RegisterFunction() - f = rf.get(fname) + f = rf.get(ns.registerfunction) x = await f(ns) if isinstance(x,Response): self.retResponse = x