diff --git a/ahserver/auth_api.py b/ahserver/auth_api.py index cafece1..615d903 100644 --- a/ahserver/auth_api.py +++ b/ahserver/auth_api.py @@ -61,12 +61,12 @@ class AuthAPI: if login_method == 'password': if await self.checkUserPassword(user_id,password): await auth.remember(request,user_id) - print('auth success,',user_id, password) + # print('auth success,',user_id, password) return user_id - print('auth failed') + # print('auth failed') raise web.HTTPUnauthorized() else: - print('auth method unrecognized------------------------') + # print('auth method unrecognized------------------------') raise web.HTTPUnauthorized() async def logout(self,request): @@ -76,19 +76,19 @@ class AuthAPI: @web.middleware async def checkAuth(self,request,handler): path = request.path - print(f'*****{path} checkAuth called********') + # print(f'*****{path} checkAuth called********') if not await self.needAuth(path): return await handler(request) user = await auth.get_auth(request) if user is None: - print('-----------auth.get_auth() return None--------------') + # print('-----------auth.get_auth() return None--------------') user = await self.checkLogin(request) #raise web.HTTPFound(f'/login_form?from_path={path}') user_perms = await self.getUserPermissions(user) need_perm = await self.getPermissionNeed(path) if need_perm in user_perms: return await handler(request) - print(f'**{path} forbidden**') + # print(f'**{path} forbidden**') raise web.HTTPForbidden() async def needAuth(self,path): diff --git a/ahserver/baseProcessor.py b/ahserver/baseProcessor.py index b7ccef9..07b1aa4 100644 --- a/ahserver/baseProcessor.py +++ b/ahserver/baseProcessor.py @@ -47,7 +47,6 @@ class BaseProcessor: def __init__(self,path,resource): self.path = path - print('self.path=',self.path) self.resource = resource self.retResponse = None # self.last_modified = os.path.getmtime(path) @@ -82,7 +81,6 @@ class BaseProcessor: indent=4) elif isinstance(self.content,DictObject): mydict = self.content.to_dict() - print('mydict=',mydict,type(mydict)) self.content = json.dumps(mydict, indent=4) elif type(self.content) == type([]): self.content = json.dumps(self.content, @@ -103,13 +101,13 @@ class TemplateProcessor(BaseProcessor): def isMe(self,name): return name=='tmpl' - async def path_call(self, request): + async def path_call(self, request, params={}): await self.set_run_env(request) path = self.path url = self.resource.entireUrl(request, path) ns = self.run_ns + ns.update(params) te = self.run_ns['tmpl_engine'] - print('****url=',url,'*****') return te.render(url,**ns) async def datahandle(self,request): @@ -146,7 +144,6 @@ class PythonScriptProcessor(BaseProcessor): def loadScript(self, path): data = '' - print('path=',path) with codecs.open(path,'rb','utf-8') as f: data = f.read() b= ''.join(data.split('\r')) @@ -155,9 +152,10 @@ class PythonScriptProcessor(BaseProcessor): txt = "async def myfunc(request,**ns):\n" + '\n'.join(lines) return txt - async def path_call(self, request): + async def path_call(self, request,params={}): await self.set_run_env(request) lenv = self.run_ns + lenv.update(params) del lenv['request'] txt = self.loadScript(self.real_path) exec(txt,lenv,lenv) @@ -165,7 +163,6 @@ class PythonScriptProcessor(BaseProcessor): return await func(request,**lenv) async def datahandle(self,request): - print('self.real_path=',self.real_path) self.content = await self.path_call(request) class MarkdownProcessor(BaseProcessor): diff --git a/ahserver/filedownload.py b/ahserver/filedownload.py index 9d7ea4b..f404863 100644 --- a/ahserver/filedownload.py +++ b/ahserver/filedownload.py @@ -30,7 +30,6 @@ async def file_download(request, filepath, content_type=None): r.content_type = 'application/octet-stream' r.content_disposition = 'attachment; filename=%s' % filename r.enable_compression() - print(filepath,filename) return r if os.path.exists(filepath): length = os.path.getsize(filepath) @@ -40,17 +39,14 @@ async def file_download(request, filepath, content_type=None): 'Content-Disposition': 'attrachment;filename={}'.format(filename) } ) - print('downloading',filepath,'size',length) await response.prepare(request) cnt = 0 with open(filepath, 'rb') as f: chunk = f.read(10240000) cnt = cnt + len(chunk) await response.write(chunk) - print('write size=',cnt) await response.fsyn() await response.write_eof() - print('end') return response raise HTTPNotFound diff --git a/ahserver/functionProcessor.py b/ahserver/functionProcessor.py index 927b76c..4a640cd 100644 --- a/ahserver/functionProcessor.py +++ b/ahserver/functionProcessor.py @@ -17,7 +17,6 @@ class FunctionProcessor(BaseProcessor): async def path_call(self, request, path): path1 = request.path[len(self.config_opts['leading']):] - print('path1=',path1) args = [] if len(path1) > 0: if path1[0] == '/': @@ -25,7 +24,6 @@ class FunctionProcessor(BaseProcessor): args = path1.split('/') - print('FunctionProcessor():args=',args) rfname = self.config_opts['registerfunction'] ns = DictObject(**self.run_ns) rf = RegisterFunction() diff --git a/ahserver/myTE.py b/ahserver/myTE.py index 5e04807..052c8fc 100644 --- a/ahserver/myTE.py +++ b/ahserver/myTE.py @@ -48,8 +48,6 @@ class TemplateEngine(Environment): def setupTemplateEngine(): config = getConfig() subffixes = [ i[0] for i in config.website.processors if i[1] == 'tmpl' ] - print(subffixes) - # paths = [ os.path.abspath(p) for p,prefix in config.website.paths ] loader = TmplLoader(config.website.paths, config.website.indexes, subffixes, diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index 13d4cb6..9d04bfe 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -95,7 +95,6 @@ class ProcessorResource(StaticResource,Url2File): def abspath(self, request, path:str): url = self.entireUrl(request, path) - print('url=',url, 'path=',path) return self.url2file(url) async def getPostData(self,request: Request) -> dict: @@ -228,11 +227,9 @@ class ProcessorResource(StaticResource,Url2File): return await processor.handle(request) filepath = self.url2file(str(request.url)) - print('filepath=',filepath,str(request.url)) if filepath and self.isHtml(filepath): return await self.html_handle(request, filepath) - print(f'path={path} handler by StaticResource..') if os.path.isdir(filepath): config = getConfig() if not config.website.allowListFolder: @@ -270,7 +267,6 @@ class ProcessorResource(StaticResource,Url2File): host = '/'.join(str(request.url).split('/')[:3]) path = url[len(host):].split('?')[0] real_path = self.abspath(request, path) - print('real_path=', real_path) if config.website.startswiths: for a in config.website.startswiths: if path.startswith(a.leading): @@ -297,7 +293,7 @@ class ProcessorResource(StaticResource,Url2File): async def path_call(self,request, path, params={}): url = self.entireUrl(request, path) processor = self.url2processor(request, url) - return await processor.path_call(request) + return await processor.path_call(request, params=params) def url_call(self,request, url,params={}): processor = self.url2processor(request, url) @@ -308,9 +304,7 @@ class ProcessorResource(StaticResource,Url2File): return processor.content long_url = self.entireUrl(request,url) hc = Http_Client() - print('url_call() called,long_url=',long_url) x = hc(long_url,method=method,params=params) - print('url_call() call finished') return x def absUrl(self,request,url): diff --git a/ahserver/restful.py b/ahserver/restful.py index 6590269..857edc6 100644 --- a/ahserver/restful.py +++ b/ahserver/restful.py @@ -53,7 +53,6 @@ class RestEndpoint: class DBCrud(RestEndpoint): def __init__(self, request,dbname,tablename, id=None): - print(f'***{dbname}*{tablename}*{id}************') super().__init__() self.dbname = dbname self.tablename = tablename diff --git a/ahserver/url2file.py b/ahserver/url2file.py index f79cc04..c8f901d 100644 --- a/ahserver/url2file.py +++ b/ahserver/url2file.py @@ -30,27 +30,22 @@ class Url2File: paths = paths[3:] f = os.path.join(self.path,*paths) real_path = os.path.abspath(f) - print('0 - url2file():real_path=', real_path,'url=',url) if os.path.isdir(real_path): for idx in self.indexes: p = os.path.join(real_path,idx) if os.path.isfile(p): - print('find it:',p, 'url=', url) return p if os.path.isfile(real_path): - print('find it here:',real_path, 'url=', url) return real_path if not self.inherit: - print('1-real_path=', real_path, ' not exists') return None items = url.split('/') if len(items) > 2: del items[-2] url = '/'.join(items) return self.url2file(url) - print('2-real_path=', real_path, ' not exists') return None def relatedurl(self,url: str, name: str) -> str: