Exemplo n.º 1
0
def colorholders(color_address=None):
  answer=databases.color_holders(color_address)
  if len(answer)==0:
    color_address=databases.first_coloraddress_from_sourceaddress(color_address)
    if not color_address is None:
      answer=databases.color_holders(color_address)
    else:
      answer=""

  colordata=databases.dbexecute("select * from colors where color_address='"+color_address+"';",True)
  source_address="not found"
  color_name="not found"
  if len(colordata)>0:
    source_address=colordata[0][1]
    color_name=colordata[0][3]
    if color_name=="color_name":
      color_name=""

  jsonresponse={}
  jsonresponse['owners']=[]
  jsonresponse['color_address']=color_address
  jsonresponse['issuing_address']=source_address
  jsonresponse['color_name']=color_name
  for x in answer:
    r={}
    r['public_address']=x
    r['quantity']=answer[x]
    jsonresponse['owners'].append(r)

  answer=json.dumps(jsonresponse)
  response=make_response(str(answer), 200)
  response.headers['Content-Type'] = 'application/json'
  response.headers['Access-Control-Allow-Origin']= '*'
  return response
Exemplo n.º 2
0
def colorholders(color_address=None):
    answer = databases.color_holders(color_address)
    if len(answer) == 0:
        color_address = databases.first_coloraddress_from_sourceaddress(
            color_address)
        if not color_address is None:
            answer = databases.color_holders(color_address)
        else:
            answer = ""

    colordata = databases.dbexecute(
        "select * from colors where color_address='" + color_address + "';",
        True)
    source_address = "not found"
    color_name = "not found"
    if len(colordata) > 0:
        source_address = colordata[0][1]
        color_name = colordata[0][3]
        if color_name == "color_name":
            color_name = ""

    jsonresponse = {}
    jsonresponse['owners'] = []
    jsonresponse['color_address'] = color_address
    jsonresponse['issuing_address'] = source_address
    jsonresponse['color_name'] = color_name

    for x in answer:
        r = {}
        r['public_address'] = x['public_address']
        r['quantity'] = x['quantity']
        jsonresponse['owners'].append(r)

    answer = json.dumps(jsonresponse)
    response = make_response(str(answer), 200)
    response.headers['Content-Type'] = 'application/json'
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response
Exemplo n.º 3
0
def colorholders(color_address=None):
  answer=databases.color_holders(color_address)
  answer=json.dumps(answer)
  response=make_response(str(answer), 200)
  response.headers['Access-Control-Allow-Origin']= '*'
  return response
Exemplo n.º 4
0
def colorholders(color_address=None):
    answer = databases.color_holders(color_address)
    answer = json.dumps(answer)
    response = make_response(str(answer), 200)
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response