first commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
@app.route('/loadconfig' , methods=['GET'])
|
||||
def loadconfig():
|
||||
user=None
|
||||
mode='text'
|
||||
try:
|
||||
user = request.args.get('userId')
|
||||
mode = request.args.get('mode')
|
||||
except HTTPException as err:
|
||||
print("http error: {0}".format(err))
|
||||
except:
|
||||
print('some error', sys.exc_info()[0])
|
||||
cfg=Dashboard(userId=user)
|
||||
resp = make_response(json.dumps({'plugs':cfg.plugs.listAsText()}))
|
||||
resp.headers['Content-type'] = 'application/json; charset=utf-8'
|
||||
return resp
|
||||
|
||||
@app.route('/loadPlugin' , methods=['GET'])
|
||||
def loadPlugin():
|
||||
try:
|
||||
plname = request.args.get('plugin')
|
||||
params = request.args.get('parameters')
|
||||
ClassType = getattr(Plugin, plname)
|
||||
p = ClassType(params)
|
||||
resp = make_response(json.dumps({'plugin':p.asHtml()}))
|
||||
except HTTPException as err:
|
||||
print("http error: {0}".format(err))
|
||||
resp = make_response(json.dumps({'plugin':err}))
|
||||
except:
|
||||
print('some error', sys.exc_info()[0])
|
||||
resp = make_response(json.dumps({'plugin':'System error loading plugin'}))
|
||||
resp.headers['Content-type'] = 'application/json; charset=utf-8'
|
||||
return resp
|
||||
|
||||
@app.route('/saveplugs' , methods=['POST'])
|
||||
def saveplugs():
|
||||
user=request.form['userId']
|
||||
mode=request.form['mode']
|
||||
plugs=request.form['plugs']
|
||||
cfg=Dashboard(userId=user)
|
||||
cfg.updatePlugs(plugs)
|
||||
cfg.save()
|
||||
resp = make_response(json.dumps({'plugs':cfg.plugs.listAsText()}))
|
||||
resp.headers['Content-type'] = 'application/json; charset=utf-8'
|
||||
return resp
|
||||
|
||||
@app.route('/json', methods=['GET'])
|
||||
def myjson():
|
||||
user=request.form['userId']
|
||||
resp = make_response(json.dumps({'plugs':'user'}))
|
||||
resp.headers['Content-type'] = 'application/json; charset=utf-8'
|
||||
return resp
|
||||
|
||||
@app.route('/upload', methods=['GET'])
|
||||
def upload():
|
||||
resp = make_response('function upload')
|
||||
resp.headers['Content-type'] = 'text/plain; charset=utf-8'
|
||||
if request.method == 'GET':
|
||||
try:
|
||||
f = request.args.get('user')
|
||||
print(f)
|
||||
except HTTPException as err:
|
||||
print("http error: {0}".format(err))
|
||||
except:
|
||||
print('some error', sys.exc_info()[0])
|
||||
return resp
|
||||
|
||||
@app.route('/echo' , methods=['GET'])
|
||||
def echo():
|
||||
text=None
|
||||
try:
|
||||
text = request.args.get('text')
|
||||
except HTTPException as err:
|
||||
print("http error: {0}".format(err))
|
||||
except:
|
||||
print('some error', sys.exc_info()[0])
|
||||
resp = make_response(text)
|
||||
resp.headers['Content-type'] = 'text/plain; charset=utf-8'
|
||||
return resp
|
||||
|
||||
Reference in New Issue
Block a user