當前位置: 首頁>>代碼示例>>Python>>正文


Python web.application方法代碼示例

本文整理匯總了Python中web.application方法的典型用法代碼示例。如果您正苦於以下問題:Python web.application方法的具體用法?Python web.application怎麽用?Python web.application使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在web的用法示例。


在下文中一共展示了web.application方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: POST

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def POST(self):
        """
        Get client key status.
        /client/status
        """
        # LDAP authentication
        is_auth, message = tools.ldap_authentification(SERVER_OPTS)
        if not is_auth:
            return tools.response_render(message, http_code='401 Unauthorized')

        payload, message = tools.data2map()
        if message:
            return tools.response_render(message, http_code='400 Bad Request')

        if 'realname' in payload:
            realname = unquote_plus(payload['realname'])
        else:
            return tools.response_render(
                'Error: No realname option given.',
                http_code='400 Bad Request')

        return tools.response_render(
            TOOLS.list_keys(realname=realname),
            content_type='application/json') 
開發者ID:nbeguier,項目名稱:cassh,代碼行數:26,代碼來源:server.py

示例2: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self, account=None, name=None):
        """
        Retrieve a subscription.

        HTTP Success:
            200 OK

        HTTP Error:
            404 Not Found
            500 Internal Error
            406 Not Acceptable

        :param account: The account name.
        :param name: The subscription name.
        """
        header('Content-Type', 'application/x-json-stream')
        try:
            for subscription in list_subscriptions(name=name, account=account):
                yield dumps(subscription, cls=APIEncoder) + '\n'
        except SubscriptionNotFound as error:
            raise generate_http_error(404, 'SubscriptionNotFound', error.args[0])
        except Exception as error:
            raise InternalError(error) 
開發者ID:rucio,項目名稱:rucio,代碼行數:25,代碼來源:subscription.py

示例3: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self, rse):
        """
        List dataset replicas replicas.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            500 InternalError

        :returns: A dictionary containing all replicas on the RSE.
        """
        header('Content-Type', 'application/x-json-stream')
        try:
            for row in list_datasets_per_rse(rse=rse):
                yield dumps(row, cls=APIEncoder) + '\n'
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error) 
開發者ID:rucio,項目名稱:rucio,代碼行數:25,代碼來源:replica.py

示例4: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self):
        """
        Retrieve all exceptions.

        HTTP Success:
            200 OK

        HTTP Error:
            404 Not Found
            406 Not Acceptable
            500 Internal Error

        """
        header('Content-Type', 'application/x-json-stream')
        try:
            for exception in list_exceptions():
                yield dumps(exception, cls=APIEncoder) + '\n'
        except LifetimeExceptionNotFound as error:
            raise generate_http_error(404, 'LifetimeExceptionNotFound', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            raise InternalError(error) 
開發者ID:rucio,項目名稱:rucio,代碼行數:25,代碼來源:lifetime_exception.py

示例5: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self, scope, name):
        """
        List archive content keys.

        HTTP Success:
            200 Success
        HTTP Error:
            406 Not Acceptable
        """
        header('Content-Type', 'application/x-json-stream')
        try:
            for file in list_archive_content(scope=scope, name=name):
                yield dumps(file) + '\n'
        except Exception as error:
            print(format_exc())
            raise InternalError(error) 
開發者ID:rucio,項目名稱:rucio,代碼行數:18,代碼來源:archive.py

示例6: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self, scope, name):
        """ List all parents of a data identifier.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
            500 InternalError

        :returns: A list of dictionary containing all dataset information.
        """
        header('Content-Type', 'application/x-json-stream')
        try:
            for dataset in list_parent_dids(scope=scope, name=name):
                yield render_json(**dataset) + "\n"
        except DataIdentifierNotFound as error:
            raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(format_exc())
            raise InternalError(error) 
開發者ID:rucio,項目名稱:rucio,代碼行數:26,代碼來源:did.py

示例7: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self):
        """
        List all heartbeats.

        HTTP Success:
            200 OK

        HTTP Error:
            401 Unauthorized
            406 Not Acceptable
        """

        header('Content-Type', 'application/json')

        return json.dumps(list_heartbeats(issuer=ctx.env.get('issuer')),
                          cls=APIEncoder) 
開發者ID:rucio,項目名稱:rucio,代碼行數:18,代碼來源:heartbeat.py

示例8: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self, rule_id):
        """ get locks for a given rule_id.

        HTTP Success:
            200 OK

        HTTP Error:
            404 Not Found
            406 Not Acceptable
            500 InternalError

        :returns: JSON dict containing informations about the requested user.
        """
        header('Content-Type', 'application/x-json-stream')
        try:
            locks = get_replica_locks_for_rule_id(rule_id)
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            raise InternalError(error)

        for lock in locks:
            yield dumps(lock, cls=APIEncoder) + '\n' 
開發者ID:rucio,項目名稱:rucio,代碼行數:25,代碼來源:rule.py

示例9: GET

# 需要導入模塊: import web [as 別名]
# 或者: from web import application [as 別名]
def GET(self):
        """
        Return ca.
        """
        return tools.response_render(
            open(SERVER_OPTS['ca'] + '.pub', 'rb'),
            content_type='application/octet-stream') 
開發者ID:nbeguier,項目名稱:cassh,代碼行數:9,代碼來源:server.py


注:本文中的web.application方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。