|
|
@ -7,6 +7,7 @@ import flask
|
|
|
|
import transport
|
|
|
|
import transport
|
|
|
|
from transport import providers
|
|
|
|
from transport import providers
|
|
|
|
import cms
|
|
|
|
import cms
|
|
|
|
|
|
|
|
from cms import Plugin
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import json
|
|
|
@ -45,8 +46,10 @@ def _getHandler (app_id,resource=None) :
|
|
|
|
_id = _getId(app_id,resource)
|
|
|
|
_id = _getId(app_id,resource)
|
|
|
|
|
|
|
|
|
|
|
|
return _route._apps[_id]
|
|
|
|
return _route._apps[_id]
|
|
|
|
def _getId(app_id,resource):
|
|
|
|
def _getId(app_id,app_x):
|
|
|
|
return '/'.join([app_id,resource]) if resource else app_id
|
|
|
|
if app_x not in [None,''] :
|
|
|
|
|
|
|
|
return '/'.join([app_id,app_x])
|
|
|
|
|
|
|
|
return app_id
|
|
|
|
def _setHandler (app_id,resource) :
|
|
|
|
def _setHandler (app_id,resource) :
|
|
|
|
session['app_id'] = _getId(app_id,resource)
|
|
|
|
session['app_id'] = _getId(app_id,resource)
|
|
|
|
|
|
|
|
|
|
|
@ -95,33 +98,14 @@ def _getIndex (app_id ,resource=None):
|
|
|
|
@_app.route("/")
|
|
|
|
@_app.route("/")
|
|
|
|
def _index ():
|
|
|
|
def _index ():
|
|
|
|
return _getIndex('main')
|
|
|
|
return _getIndex('main')
|
|
|
|
# def _xindex ():
|
|
|
|
|
|
|
|
# _handler = _getHandler()
|
|
|
|
|
|
|
|
# _config = _handler.config()
|
|
|
|
|
|
|
|
# global _route
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # print ([' serving ',session.get('app_id','NA'),_handler.layout()['root']])
|
|
|
|
|
|
|
|
# _args={'system':_handler.system(skip=['source','app','data']),'layout':_handler.layout()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
|
|
|
# uri = os.sep.join([_config['layout']['root'], _config['layout']['index']])
|
|
|
|
|
|
|
|
# _index_page = "index.html"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# _args = _route.render(uri,'index',session.get('app_id','main'))
|
|
|
|
|
|
|
|
# # _setHandler('main')
|
|
|
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
|
|
|
# # print ()
|
|
|
|
|
|
|
|
# print (e)
|
|
|
|
|
|
|
|
# _index_page = "404.html"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# return render_template(_index_page,**_args),200 if _index_page != "404.html" else 200
|
|
|
|
|
|
|
|
@_app.route("/<app>/<resource>")
|
|
|
|
@_app.route("/<app>/<resource>")
|
|
|
|
@_app.route("/<app>",defaults={'resource':None})
|
|
|
|
@_app.route("/<app>",defaults={'resource':None})
|
|
|
|
def _aindex (app,resource=None):
|
|
|
|
def _aindex (app,resource=None):
|
|
|
|
_handler = _getHandler(app,resource)
|
|
|
|
_handler = _getHandler(app,resource)
|
|
|
|
|
|
|
|
|
|
|
|
_setHandler(app,resource)
|
|
|
|
_setHandler(app,resource)
|
|
|
|
_html,_code = _getIndex(app,resource)
|
|
|
|
_html,_code = _getIndex(app,resource)
|
|
|
|
|
|
|
|
|
|
|
|
return _html,_code
|
|
|
|
return _html,_code
|
|
|
|
# @_app.route('/id/<uid>')
|
|
|
|
# @_app.route('/id/<uid>')
|
|
|
|
# def people(uid):
|
|
|
|
# def people(uid):
|
|
|
@ -144,28 +128,16 @@ def _dialog (app):
|
|
|
|
_args['title'] = _id
|
|
|
|
_args['title'] = _id
|
|
|
|
return render_template('dialog.html',**_args) #title=_id,html=_html)
|
|
|
|
return render_template('dialog.html',**_args) #title=_id,html=_html)
|
|
|
|
|
|
|
|
|
|
|
|
@_app.route("/api/<module>/<name>",defaults={'app':'main','key':None})
|
|
|
|
@_app.route("/api/<module>/<name>",defaults={'app':'main','key':None},methods=['GET','POST','DELETE','PUT'])
|
|
|
|
@_app.route("/<app>/api/<module>/<name>",defaults={'key':None})
|
|
|
|
@_app.route("/<app>/api/<module>/<name>",defaults={'key':None},methods=['GET','POST','DELETE','PUT'])
|
|
|
|
@_app.route("/<app>/<key>/<module>/<name>",defaults={'key':None})
|
|
|
|
@_app.route("/<app>/<key>/api/<module>/<name>",methods=['GET','POST','DELETE','PUT'])
|
|
|
|
|
|
|
|
|
|
|
|
def _delegate_call(app,key,module,name):
|
|
|
|
def _delegate_call(app,key,module,name):
|
|
|
|
_handler = _getHandler(app,key)
|
|
|
|
_handler = _getHandler(app,key)
|
|
|
|
return _delegate(_handler,module,name)
|
|
|
|
# print (_handler.config()/)
|
|
|
|
|
|
|
|
uri = f'api/{module}/{name}'
|
|
|
|
# @_app.route('/api/<module>/<name>')
|
|
|
|
return Plugin.call(uri=uri,handler=_handler,request=request)
|
|
|
|
@_app.route("/<app_id>/<key>/api/<module>/<name>", methods=['GET'])
|
|
|
|
# return _delegate(_handler,module,name)
|
|
|
|
@_app.route("/api/<module>/<name>",defaults={'app_id':'main','key':None})
|
|
|
|
|
|
|
|
@_app.route("/<app_id>/api/<module>/<name>",defaults={'key':None})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api(app_id,key,module,name) :
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
This endpoint will load a module and make a function call
|
|
|
|
|
|
|
|
:_module entry specified in plugins of the configuration
|
|
|
|
|
|
|
|
:_name name of the function to execute
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_handler = _getHandler( app_id,key)
|
|
|
|
|
|
|
|
return _delegate(_handler,module,name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _delegate(_handler,module,name):
|
|
|
|
def _delegate(_handler,module,name):
|
|
|
|
global _route
|
|
|
|
global _route
|
|
|
@ -186,10 +158,13 @@ def _delegate(_handler,module,name):
|
|
|
|
# _data = pointer (**_args)
|
|
|
|
# _data = pointer (**_args)
|
|
|
|
# else:
|
|
|
|
# else:
|
|
|
|
# _data = pointer()
|
|
|
|
# _data = pointer()
|
|
|
|
|
|
|
|
if hasattr(pointer,'mimetype') :
|
|
|
|
|
|
|
|
_data = pointer(request=request,config=_handler.config())
|
|
|
|
|
|
|
|
_mimeType = pointer.mimetype
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
_data,_mimeType = pointer(request=request,config=_handler.config())
|
|
|
|
|
|
|
|
|
|
|
|
_data,_mimeType = pointer(request=request,config=_handler.config())
|
|
|
|
_mimeType = 'application/octet-stream' if not _mimeType else _mimeType
|
|
|
|
|
|
|
|
|
|
|
|
_mimeType = 'application/octet-stream' if not _mimeType else _mimeType
|
|
|
|
|
|
|
|
if type(_data) == pd.DataFrame :
|
|
|
|
if type(_data) == pd.DataFrame :
|
|
|
|
_data = _data.to_dict(orient='records')
|
|
|
|
_data = _data.to_dict(orient='records')
|
|
|
|
if type(_data) == list:
|
|
|
|
if type(_data) == list:
|
|
|
@ -201,18 +176,18 @@ def _delegate(_handler,module,name):
|
|
|
|
# @_app.route('/<app_id>/api/<module>/<name>',methods=['POST'],defaults={'key':None})
|
|
|
|
# @_app.route('/<app_id>/api/<module>/<name>',methods=['POST'],defaults={'key':None})
|
|
|
|
# @_app.route('/<app_id>/<key>/api/<module>/<name>',methods=['POST'],defaults={'app_id':'main','key':None})
|
|
|
|
# @_app.route('/<app_id>/<key>/api/<module>/<name>',methods=['POST'],defaults={'app_id':'main','key':None})
|
|
|
|
|
|
|
|
|
|
|
|
@_app.route("/<app_id>/<key>/api/<module>/<name>", methods=['POST'])
|
|
|
|
# @_app.route("/<app_id>/<key>/api/<module>/<name>", methods=['POST'])
|
|
|
|
@_app.route("/api/<module>/<name>",defaults={'app_id':'main','key':None},methods=['POST'])
|
|
|
|
# @_app.route("/api/<module>/<name>",defaults={'app_id':'main','key':None},methods=['POST'])
|
|
|
|
@_app.route("/<app_id>/api/<module>/<name>",defaults={'key':None},methods=['POST'])
|
|
|
|
# @_app.route("/<app_id>/api/<module>/<name>",defaults={'key':None},methods=['POST'])
|
|
|
|
|
|
|
|
|
|
|
|
def _post (app_id,key,module,name):
|
|
|
|
# def _post (app_id,key,module,name):
|
|
|
|
# global _config
|
|
|
|
# # global _config
|
|
|
|
# global _route
|
|
|
|
# # global _route
|
|
|
|
# _handler = _route.get()
|
|
|
|
# # _handler = _route.get()
|
|
|
|
# app_id = '/'.join([app_id,key]) if key else app_id
|
|
|
|
# # app_id = '/'.join([app_id,key]) if key else app_id
|
|
|
|
|
|
|
|
|
|
|
|
_handler = _getHandler(app_id,key)
|
|
|
|
# _handler = _getHandler(app_id,key)
|
|
|
|
return _delegate(_handler,module,name)
|
|
|
|
# return _delegate(_handler,module,name)
|
|
|
|
|
|
|
|
|
|
|
|
@_app.route('/version')
|
|
|
|
@_app.route('/version')
|
|
|
|
def _version ():
|
|
|
|
def _version ():
|
|
|
@ -310,31 +285,6 @@ def _cms_page (app_id,resource):
|
|
|
|
_args = _route.render(_uri,_title,session.get(app_id,'main'))
|
|
|
|
_args = _route.render(_uri,_title,session.get(app_id,'main'))
|
|
|
|
return _args[_title],200
|
|
|
|
return _args[_title],200
|
|
|
|
|
|
|
|
|
|
|
|
# @_app.route('/set/<id>')
|
|
|
|
|
|
|
|
# def set(id):
|
|
|
|
|
|
|
|
# global _route
|
|
|
|
|
|
|
|
# _setHandler(id)
|
|
|
|
|
|
|
|
# # _route.set(id)
|
|
|
|
|
|
|
|
# # _handler = _route.get()
|
|
|
|
|
|
|
|
# _handler = _getHandler()
|
|
|
|
|
|
|
|
# _context = _handler.system()['context']
|
|
|
|
|
|
|
|
# _uri = f'/{_context}'.replace('//','/')
|
|
|
|
|
|
|
|
# return redirect(_uri)
|
|
|
|
|
|
|
|
# @_app.route('/<id>')
|
|
|
|
|
|
|
|
# def _open(id):
|
|
|
|
|
|
|
|
# global _route
|
|
|
|
|
|
|
|
# # _handler = _route.get()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# _handler = _getHandler()
|
|
|
|
|
|
|
|
# if id not in _route._apps :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# _args = {'config':_handler.config(), 'layout':_handler.layout(),'system':_handler.system(skip=['source','app'])}
|
|
|
|
|
|
|
|
# return render_template("404.html",**_args)
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
# _setHandler(id)
|
|
|
|
|
|
|
|
# # _route.set(id)
|
|
|
|
|
|
|
|
# return _index()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@cli.command()
|
|
|
|
def start (
|
|
|
|
def start (
|
|
|
|