Compare commits
2 Commits
95ce487258
...
21143f0138
Author | SHA1 | Date | |
---|---|---|---|
|
21143f0138 | ||
|
9cd3bfe539 |
@ -136,7 +136,7 @@ class TemplateProcessor(BaseProcessor):
|
|||||||
url = self.resource.entireUrl(request, path)
|
url = self.resource.entireUrl(request, path)
|
||||||
ns = self.run_ns
|
ns = self.run_ns
|
||||||
te = self.run_ns['tmpl_engine']
|
te = self.run_ns['tmpl_engine']
|
||||||
print(f'{url=}, {path=}')
|
# print(f'{url=}, {path=}')
|
||||||
# return await te.render(url,**ns)
|
# return await te.render(url,**ns)
|
||||||
return await te.render(path,**ns)
|
return await te.render(path,**ns)
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class TemplateProcessor(BaseProcessor):
|
|||||||
class BricksUIProcessor(TemplateProcessor):
|
class BricksUIProcessor(TemplateProcessor):
|
||||||
@classmethod
|
@classmethod
|
||||||
def isMe(self,name):
|
def isMe(self,name):
|
||||||
print(f'{name=} is a bui')
|
# print(f'{name=} is a bui')
|
||||||
return name=='bui'
|
return name=='bui'
|
||||||
|
|
||||||
async def datahandle(self, request):
|
async def datahandle(self, request):
|
||||||
@ -215,7 +215,7 @@ class MarkdownProcessor(BaseProcessor):
|
|||||||
mdtxt)
|
mdtxt)
|
||||||
|
|
||||||
def getProcessor(name):
|
def getProcessor(name):
|
||||||
print(f'getProcessor({name})')
|
# print(f'getProcessor({name})')
|
||||||
return _getProcessor(BaseProcessor, name)
|
return _getProcessor(BaseProcessor, name)
|
||||||
|
|
||||||
def _getProcessor(kclass,name):
|
def _getProcessor(kclass,name):
|
||||||
|
@ -18,7 +18,7 @@ class TmplLoader(BaseLoader, TmplUrl2File):
|
|||||||
coding = config.website.coding
|
coding = config.website.coding
|
||||||
|
|
||||||
fp = self.url2file(template)
|
fp = self.url2file(template)
|
||||||
print(f'{template=} can not transfer to filename')
|
# print(f'{template=} can not transfer to filename')
|
||||||
if not os.path.isfile(fp):
|
if not os.path.isfile(fp):
|
||||||
raise TemplateNotFound(template)
|
raise TemplateNotFound(template)
|
||||||
mtime = os.path.getmtime(fp)
|
mtime = os.path.getmtime(fp)
|
||||||
|
@ -167,6 +167,27 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
|
|||||||
# print(f'getPostData():{ns=}')
|
# print(f'getPostData():{ns=}')
|
||||||
return ns
|
return ns
|
||||||
|
|
||||||
|
def parse_request(self, request):
|
||||||
|
"""
|
||||||
|
get real schema, host, port, prepath
|
||||||
|
and save it to self._{attr}
|
||||||
|
|
||||||
|
"""
|
||||||
|
self._scheme = request.scheme
|
||||||
|
|
||||||
|
self._scheme = request.headers.get('X-Forwarded-Scheme',request.scheme)
|
||||||
|
k = request.host.split(':')
|
||||||
|
host = k[0]
|
||||||
|
port = 80
|
||||||
|
if len(k) == 2:
|
||||||
|
port = int(k[1])
|
||||||
|
elif self._scheme.lower() == 'https':
|
||||||
|
port = 443
|
||||||
|
|
||||||
|
self._host = request.headers.get('X-Forwarded-Host', host)
|
||||||
|
self._port = request.headers.get('X-Forwarded-Port', port)
|
||||||
|
self._prepath = request.headers.get('X-Forwarded-Prepath', '')
|
||||||
|
|
||||||
async def _handle(self,request:Request) -> StreamResponse:
|
async def _handle(self,request:Request) -> StreamResponse:
|
||||||
clientkeys = {
|
clientkeys = {
|
||||||
"iPhone":"iphone",
|
"iPhone":"iphone",
|
||||||
@ -231,6 +252,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
|
|||||||
async def get_user():
|
async def get_user():
|
||||||
return await auth.get_auth(request)
|
return await auth.get_auth(request)
|
||||||
|
|
||||||
|
self.parse_request(request)
|
||||||
|
|
||||||
self.y_env.i18n = serveri18n
|
self.y_env.i18n = serveri18n
|
||||||
self.y_env.file_realpath = file_realpath
|
self.y_env.file_realpath = file_realpath
|
||||||
self.y_env.redirect = redirect
|
self.y_env.redirect = redirect
|
||||||
@ -301,7 +324,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
|
|||||||
if not config.website.allowListFolder:
|
if not config.website.allowListFolder:
|
||||||
self.error('%s:not found' % str(request.url))
|
self.error('%s:not found' % str(request.url))
|
||||||
raise HTTPNotFound
|
raise HTTPNotFound
|
||||||
print(f'{self.request_filename=}, {str(request.url)=} handle as a normal file')
|
# print(f'{self.request_filename=}, {str(request.url)=} handle as a normal file')
|
||||||
return await super()._handle(request)
|
return await super()._handle(request)
|
||||||
|
|
||||||
def gethost(self, request):
|
def gethost(self, request):
|
||||||
@ -393,7 +416,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File):
|
|||||||
|
|
||||||
async def path_call(self, request, path, params={}):
|
async def path_call(self, request, path, params={}):
|
||||||
url = self.entireUrl(request, path)
|
url = self.entireUrl(request, path)
|
||||||
print(f'{path=}, after entireUrl(), {url=}')
|
# print(f'{path=}, after entireUrl(), {url=}')
|
||||||
fpath = self.url2file(url)
|
fpath = self.url2file(url)
|
||||||
processor = self.url2processor(request, url, fpath)
|
processor = self.url2processor(request, url, fpath)
|
||||||
new_request = request.clone(rel_url=url)
|
new_request = request.clone(rel_url=url)
|
||||||
|
Loading…
Reference in New Issue
Block a user