dbot-server/app/api/dbots/v1.py
def post(self):
        """
        New a Dbot
        This API need authorization with signature in headers
        """
        # TODO request data valid check
        profile = request.files['profile']
        specification = request.files['specification']
        form = request.form
        dbot_data = json.load(profile)

        domain = form.get('domain', dbot_data['info'].get('domain'))
        if domain is None:
            abort(400, message="DBot domain is required")
        dbot_data['info'].update({
            'addr': form['address'],
            'owner': form['owner'],
            'floor_price': form['floor_price'],
            'api_host': form['api_host'],
            'protocol': form['protocol'],
            'domain': domain
        })
        dbot_data['specification']['data'] = specification.read().decode('utf-8')
        address = to_checksum_address(dbot_data['info'].get('addr'))
        if db.dbots.get(address) is not None:
            abort(404, message="Bad Request, can not insert an exsit DBot service")
        dbot_data['info']['addr'] = address
        middleware = None
        try:
            mw = dbot_data.get('middleware')
            if mw:
                mw_path = os.path.join(db.path(), 'middleware/{}'.format(address))
                if not os.path.exists(mw_path):
                    os.makedirs(mw_path)
                request.files.get('middleware').save(os.path.join(mw_path, '{}.py'.format(mw['module'])))
                middleware = getattr(load_module(mw['module'], mw_path), mw['class'])
        except Exception as err:
            abort(400, message='unable to load DBot middleware: {}'.format(err))
        try:
            dbot.new_service(dbot_data, middleware)
        except Exception as err:
            abort(400, message=str(err))
        db.dbots.put(address, dbot_data)

        return 'ok', 200

        New a Dbot
        This API need authorization with signature in headers
        
New a Dbot
This API need authorization with signature in headers
New a Dbot This API need authorization with signature in headers
def post(self):
        profile = request.files['profile']
        specification = request.files['specification']
        form = request.form
        dbot_data = json.load(profile)
        domain = form.get('domain', dbot_data['info'].get('domain'))
        if domain is None:
            abort(400, message="DBot domain is required")
        dbot_data['info'].update({
            'addr': form['address'],
            'owner': form['owner'],
            'floor_price': form['floor_price'],
            'api_host': form['api_host'],
            'protocol': form['protocol'],
            'domain': domain
        })
        dbot_data['specification']['data'] = specification.read().decode('utf-8')
        address = to_checksum_address(dbot_data['info'].get('addr'))
        if db.dbots.get(address) is not None:
            abort(404, message="Bad Request, can not insert an exsit DBot service")
        dbot_data['info']['addr'] = address
        middleware = None
        try:
            mw = dbot_data.get('middleware')
            if mw:
                mw_path = os.path.join(db.path(), 'middleware/{}'.format(address))
                if not os.path.exists(mw_path):
                    os.makedirs(mw_path)
                request.files.get('middleware').save(os.path.join(mw_path, '{}.py'.format(mw['module'])))
                middleware = getattr(load_module(mw['module'], mw_path), mw['class'])
        except Exception as err:
            abort(400, message='unable to load DBot middleware: {}'.format(err))
        try:
            dbot.new_service(dbot_data, middleware)
        except Exception as err:
            abort(400, message=str(err))
        db.dbots.put(address, dbot_data)
        return 'ok', 200
def post ( self ) : profile = request . files [ 'profile' ] specification = request . files [ 'specification' ] form = request . form dbot_data = json . load ( profile ) domain = form . get ( 'domain' , dbot_data [ 'info' ] . get ( 'domain' ) ) if domain is None : abort ( 400 , message = "DBot domain is required" ) dbot_data [ 'info' ] . update ( { 'addr' : form [ 'address' ] , 'owner' : form [ 'owner' ] , 'floor_price' : form [ 'floor_price' ] , 'api_host' : form [ 'api_host' ] , 'protocol' : form [ 'protocol' ] , 'domain' : domain } ) dbot_data [ 'specification' ] [ 'data' ] = specification . read ( ) . decode ( 'utf-8' ) address = to_checksum_address ( dbot_data [ 'info' ] . get ( 'addr' ) ) if db . dbots . get ( address ) is not None : abort ( 404 , message = "Bad Request, can not insert an exsit DBot service" ) dbot_data [ 'info' ] [ 'addr' ] = address middleware = None try : mw = dbot_data . get ( 'middleware' ) if mw : mw_path = os . path . join ( db . path ( ) , 'middleware/{}' . format ( address ) ) if not os . path . exists ( mw_path ) : os . makedirs ( mw_path ) request . files . get ( 'middleware' ) . save ( os . path . join ( mw_path , '{}.py' . format ( mw [ 'module' ] ) ) ) middleware = getattr ( load_module ( mw [ 'module' ] , mw_path ) , mw [ 'class' ] ) except Exception as err : abort ( 400 , message = 'unable to load DBot middleware: {}' . format ( err ) ) try : dbot . new_service ( dbot_data , middleware ) except Exception as err : abort ( 400 , message = str ( err ) ) db . dbots . put ( address , dbot_data ) return 'ok' , 200
New a Dbot
This API need authorization with signature in headers
New a Dbot This API need authorization with signature in headers
"""
        New a Dbot
        This API need authorization with signature in headers
        """ # TODO request data valid check
self