refactoring ...

This commit is contained in:
Steve Nyemba 2022-10-20 14:20:31 -05:00
parent 1fa80367a4
commit 579e15f8f7
4 changed files with 25 additions and 22 deletions

View File

@ -67,4 +67,9 @@ class components :
return _data return _data
def csv(uri) : def csv(uri) :
return pd.read(uri).to_html() return pd.read(uri).to_html()
def apply(**_args):
"""
:uri uri of the mapping function
:args arguments of the function
"""

View File

@ -1,10 +0,0 @@
class Project :
@staticmethod
def create (**_args) :
_version = "0.0.1" if "version" not in _args else _args['version']
_context = "" if 'context' not in _args else _args['context']
_logo = "logo.png"
_system = {"version":_version,"context":_context,"logo":_logo}
_app = {"port":8084,"debug":True}
pass

View File

@ -25,15 +25,22 @@ def favicon():
@_app.route("/") @_app.route("/")
def _index (): def _index ():
global _config global _config
_args = {'system':_config['system']} _args = {}
_args['layout'] = _config['layout'] try:
# _args = dict(_args,**_config['layout']) _args = {'system':_config['system']}
# _args = copy.copy(_config) _args['layout'] = _config['layout']
uri = os.sep.join([_config['layout']['root'], _config['layout']['index']]) # _args = dict(_args,**_config['layout'])
_html = cms.components.html(uri,'index') # _args = copy.copy(_config)
e = Environment(loader=BaseLoader()).from_string(_html) uri = os.sep.join([_config['layout']['root'], _config['layout']['index']])
_args['index'] = e.render(**_args) _html = cms.components.html(uri,'index')
return render_template("index.html",**_args) e = Environment(loader=BaseLoader()).from_string(_html)
_args['index'] = e.render(**_args)
_index_page = "index.html"
except Exception as e:
_index_page = "404.html"
pass
return render_template(_index_page,**_args)
@_app.route('/id/<uid>') @_app.route('/id/<uid>')
def people(uid): def people(uid):
@ -43,7 +50,7 @@ def people(uid):
global _config global _config
return "0",200 return "0",200
@_app.route('/cms/dialog') @_app.route('/dialog')
def _dialog (): def _dialog ():
global _config global _config
_uri = os.sep.join([_config['layout']['root'],request.headers['uri']]) _uri = os.sep.join([_config['layout']['root'],request.headers['uri']])
@ -63,7 +70,7 @@ def _dialog ():
# _html = ( e.render(**_args)) # _html = ( e.render(**_args))
@_app.route('/cms/page',methods=['POST']) @_app.route('/page',methods=['POST'])
def cms_page(): def cms_page():
""" """
return the content of a folder formatted for a menu return the content of a folder formatted for a menu
@ -103,6 +110,7 @@ if len(sys.argv) > 1:
i += 2 i += 2
if __name__ == '__main__' : if __name__ == '__main__' :
_path = SYS_ARGS['config'] if 'config' in SYS_ARGS else 'config.json' _path = SYS_ARGS['config'] if 'config' in SYS_ARGS else 'config.json'
if os.path.exists(_path): if os.path.exists(_path):
_config = json.loads((open (_path)).read()) _config = json.loads((open (_path)).read())

0
templates/404.html Normal file
View File