コード例 #1
0
    def toJSON(self):
        obj = {
            'data': {
                'staker': self.staker,
                'claimable_stake': self.claimable_stake,
                'token': {
                    'name': self.token.name,
                    'symbol': self.token.symbol,
                    'address': self.token.address
                },
                'minimum_fee': self.minimum_fee,
                'data': self.data,
                'claim_deadline': str( int(Decimal(self.claim_deadline.real)) ),
                'arbiter': {
                    'name': '',
                    'description': '',
                    'address': self.arbiter.address
                },
                'whitelist': [w.claimant for w in self.whitelist],
                'claims': [json.loads(c.toJSON()) for c in self.claims],
                'settlements': [] # TODO
            },
            'errors': []
        }

        return json.dumps(obj)
コード例 #2
0
def _recognize(image_file):
    files = {
        'image': (image_file, open(image_file, 'rb')),
    }

    response = requests.post('https://api.openalpr.com/v2/recognize',
                             params=params,
                             files=files)
    return json.dumps(response)
コード例 #3
0
 def on_post(self, req, resp, args):
     name = args['name']
     surname = args['surname']
     birthdate = args['birthdate']
     zip_code = args['zip_code']
     user = self.user_service.create_user(name=name,
                                          surname=surname,
                                          birthdate=birthdate,
                                          zip_code=zip_code)
     resp.body = json.dumps(user.to_dict())
コード例 #4
0
 def on_post(self, req, resp):
     image = req.get_param("image")
     ext = mimetypes.guess_extension(req.content_type)
     filename = "{uuid}{ext}".format(uuid=uuid.uuid4(), ext=ext)
     image_path = os.path.join(self._storage_path, filename)
     with open(image_path, "wb") as image_file:
         while True:
             chunk = image.file.read(4096)
             image_file.write(chunk)
             if not chunk:
                 break
     resp.status = falcon.HTTP_200
     resp.location = filename
     # resp.body = json.dumps("{name:" + image_path + "}")
     resp.body = json.dumps(
         _recognize(image_path))  # TODO try except and read from DB
コード例 #5
0
    def process_response(self, req, resp, resource, req_succeeded):
        if not hasattr(resp.context, "result"):
            return

        resp.body = json.dumps(resp.context.result)
コード例 #6
0
    def process_response(self, req, resp, resource):
        if "result" not in req.context:
            return

        resp.body = json.dumps(req.context["result"])
コード例 #7
0
ファイル: root.py プロジェクト: lightclient/DelphiAPI
 def on_post(self, req, resp, name):
     resp.body = json.dumps(
         {"message": "Hello, {}!".format(name.capitalize())})
コード例 #8
0
ファイル: root.py プロジェクト: lightclient/DelphiAPI
 def on_get(self, req, resp):
     resp.body = json.dumps({
         "message": "Hello, World!",
     })
コード例 #9
0
 def on_delete(self, req, resp, args):
     self.user_service.delete_user(args['user_id'])
     resp.body = json.dumps({'success': True})
コード例 #10
0
    def on_post(self, req, resp, args):
        name = args['name']
        surname = args['surname']

        user = self.user_service.create_user(name=name, surname=surname)
        resp.body = json.dumps(user.to_dict())
コード例 #11
0
 def on_get(self, req, resp):
     resp.body = json.dumps(
         [u.to_dict() for u in self.user_service.list_users()])
コード例 #12
0
 def on_get(self, req, resp):
     resp.body = json.dumps({
         "message": "GAF!",
     })