|
|
|
@ -7,6 +7,7 @@ import flask
|
|
|
|
|
import transport
|
|
|
|
|
from transport import providers
|
|
|
|
|
import cms
|
|
|
|
|
from cms import Plugin
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import json
|
|
|
|
@ -144,28 +145,16 @@ def _dialog (app):
|
|
|
|
|
_args['title'] = _id
|
|
|
|
|
return render_template('dialog.html',**_args) #title=_id,html=_html)
|
|
|
|
|
|
|
|
|
|
@_app.route("/api/<module>/<name>",defaults={'app':'main','key':None})
|
|
|
|
|
@_app.route("/<app>/api/<module>/<name>",defaults={'key':None})
|
|
|
|
|
@_app.route("/<app>/<key>/<module>/<name>",defaults={'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},methods=['GET','POST','DELETE','PUT'])
|
|
|
|
|
@_app.route("/<app>/<key>/<module>/<name>",defaults={'key':None},methods=['GET','POST','DELETE','PUT'])
|
|
|
|
|
|
|
|
|
|
def _delegate_call(app,key,module,name):
|
|
|
|
|
_handler = _getHandler(app,key)
|
|
|
|
|
return _delegate(_handler,module,name)
|
|
|
|
|
|
|
|
|
|
# @_app.route('/api/<module>/<name>')
|
|
|
|
|
@_app.route("/<app_id>/<key>/api/<module>/<name>", methods=['GET'])
|
|
|
|
|
@_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)
|
|
|
|
|
# print (_handler.config()/)
|
|
|
|
|
uri = f'api/{module}/{name}'
|
|
|
|
|
return Plugin.call(uri=uri,handler=_handler,request=request)
|
|
|
|
|
# return _delegate(_handler,module,name)
|
|
|
|
|
|
|
|
|
|
def _delegate(_handler,module,name):
|
|
|
|
|
global _route
|
|
|
|
@ -186,7 +175,10 @@ def _delegate(_handler,module,name):
|
|
|
|
|
# _data = pointer (**_args)
|
|
|
|
|
# else:
|
|
|
|
|
# _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())
|
|
|
|
|
|
|
|
|
|
_mimeType = 'application/octet-stream' if not _mimeType else _mimeType
|
|
|
|
@ -201,18 +193,18 @@ def _delegate(_handler,module,name):
|
|
|
|
|
# @_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'])
|
|
|
|
|
@_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>/<key>/api/<module>/<name>", 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'])
|
|
|
|
|
|
|
|
|
|
def _post (app_id,key,module,name):
|
|
|
|
|
# global _config
|
|
|
|
|
# global _route
|
|
|
|
|
# _handler = _route.get()
|
|
|
|
|
# app_id = '/'.join([app_id,key]) if key else app_id
|
|
|
|
|
# def _post (app_id,key,module,name):
|
|
|
|
|
# # global _config
|
|
|
|
|
# # global _route
|
|
|
|
|
# # _handler = _route.get()
|
|
|
|
|
# # app_id = '/'.join([app_id,key]) if key else app_id
|
|
|
|
|
|
|
|
|
|
_handler = _getHandler(app_id,key)
|
|
|
|
|
return _delegate(_handler,module,name)
|
|
|
|
|
# _handler = _getHandler(app_id,key)
|
|
|
|
|
# return _delegate(_handler,module,name)
|
|
|
|
|
|
|
|
|
|
@_app.route('/version')
|
|
|
|
|
def _version ():
|
|
|
|
@ -310,31 +302,6 @@ def _cms_page (app_id,resource):
|
|
|
|
|
_args = _route.render(_uri,_title,session.get(app_id,'main'))
|
|
|
|
|
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()
|
|
|
|
|
def start (
|
|
|
|
|