checkifchange
This commit is contained in:
parent
18e3ee7d5c
commit
a7adbf9f8f
@ -47,11 +47,10 @@ class BaseProcessor:
|
|||||||
self.path = path
|
self.path = path
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
self.retResponse = None
|
self.retResponse = None
|
||||||
self.last_modified = os.path.getmtime(path)
|
# self.last_modified = os.path.getmtime(path)
|
||||||
self.content_length = os.path.getsize(path)
|
# self.content_length = os.path.getsize(path)
|
||||||
self.headers = {
|
self.headers = {
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html; utf-8',
|
||||||
'Content-Length': str(self.content_length),
|
|
||||||
'Accept-Ranges': 'bytes'
|
'Accept-Ranges': 'bytes'
|
||||||
}
|
}
|
||||||
self.content = ''
|
self.content = ''
|
||||||
@ -93,9 +92,9 @@ class TemplateProcessor(BaseProcessor):
|
|||||||
async def datahandle(self,request):
|
async def datahandle(self,request):
|
||||||
path = request.path
|
path = request.path
|
||||||
ns = self.run_ns
|
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 = te.render(path,**ns)
|
||||||
#self.content = await te.render_async(path,**ns)
|
|
||||||
|
|
||||||
def setheaders(self):
|
def setheaders(self):
|
||||||
super(TemplateProcessor,self).setheaders()
|
super(TemplateProcessor,self).setheaders()
|
||||||
@ -125,6 +124,7 @@ class PythonScriptProcessor(BaseProcessor):
|
|||||||
async def datahandle(self,request):
|
async def datahandle(self,request):
|
||||||
g = ServerEnv()
|
g = ServerEnv()
|
||||||
lenv = self.run_ns
|
lenv = self.run_ns
|
||||||
|
del lenv['request']
|
||||||
if not g.get('dspy_cache',False):
|
if not g.get('dspy_cache',False):
|
||||||
g.dspy_cache = ObjectCache()
|
g.dspy_cache = ObjectCache()
|
||||||
func = g.dspy_cache.get(self.path)
|
func = g.dspy_cache.get(self.path)
|
||||||
|
@ -12,14 +12,14 @@ class FunctionProcessor(BaseProcessor):
|
|||||||
|
|
||||||
def __init__(self,path,resource, opts):
|
def __init__(self,path,resource, opts):
|
||||||
self.config_opts = opts
|
self.config_opts = opts
|
||||||
|
BaseProcessor.__init__(self,path,resource)
|
||||||
|
|
||||||
async def datahandle(self,request):
|
async def datahandle(self,request):
|
||||||
ns = self.config_opts.options.copy()
|
ns = self.config_opts.copy()
|
||||||
ns.update(self.run_ns)
|
ns.update(self.run_ns)
|
||||||
ns = DictObject(ns)
|
ns = DictObject(**ns)
|
||||||
fname = self.config_opts.registerfunction
|
|
||||||
rf = RegisterFunction()
|
rf = RegisterFunction()
|
||||||
f = rf.get(fname)
|
f = rf.get(ns.registerfunction)
|
||||||
x = await f(ns)
|
x = await f(ns)
|
||||||
if isinstance(x,Response):
|
if isinstance(x,Response):
|
||||||
self.retResponse = x
|
self.retResponse = x
|
||||||
|
Loading…
Reference in New Issue
Block a user