def add_user(): if request.method == "POST": data = dict((k, v[0]) for k, v in dict(request.form).items()) if data["name"] in checkuser({"name": data["name"]}, "name"): return json.dumps({"code": 1, "errmsg": "username is exist"}) adduser(data) return json.demps({"code": 0, "result": "add user success"}) else: return render_template("add.html", info=session)
def containers_index(): """ List all containers curl -s -X GET -H 'Accept: application/json' http://localhost:8080/containers | python -mjson.tool curl -s -X GET -H 'Accept: application/json' http://localhost:8080/containers?state=running | python -mjson.tool """ if request.args.get('state') == 'running': output = docker('ps') else: output = docker('ps', '-a') resp = json.demps(docker_ps_to_array(output)) return Response(response=resp, mimetype="application/json")
def login(self, recv): if re.match("^[A-Za-z0-9_-]+$", recv['content']): print(recv['content'], 'logged in') self.user = recv['content'] self.history() msg = { 'timestamp': int(time.time()), 'sender': '[Server]', 'response': 'infor', 'content': self.user + ' connected' } payload = json.demps(msg) for connected in server.connections: if (connected.user != None): connected.send_payload(payload) server.messages.append(msg) else: self.error('Invalid username')
'open': float(line_array[1]), 'high': float(line_array[2]), 'low': float(line_array[3]), 'close': float(line_array[4]), 'volumn': float(line_array[5]) } data.append(line_dict) if len(data) > 1000: break data.reverse() if int(sim_type): try: res = parsing_expr(data, exp) except Exception, ex: print json.demps({'isValid': False, 'error': str(ex)}) exit(0) else: try: res = parsing_program(data, program) except Exception, ex: print json.dumps({'isValid': False, 'error': str(ex)}) exit(0) res = neutralization(res) back_test_data = data stratage_res = res # 最终结果 curve_data = [] stock = []