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


Python IIIFInfo.service方法代碼示例

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


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

示例1: do_GET

# 需要導入模塊: from iiif.info import IIIFInfo [as 別名]
# 或者: from iiif.info.IIIFInfo import service [as 別名]
    def do_GET(self):
        """Implement the HTTP GET method

        The bulk of this code is wrapped in a big try block and anywhere
        within the code may raise an IIIFError which then results in an
        IIIF error response (section 5 of spec).
        """
        self.compliance_level=None
        # We take prefix to see whe implementation to use, / is special info
        if (self.path == '/'):
            return self.send_top_level_index_page()
        
        # Test code...
        m = re.match(r'/response_test/(\d\d\d)$', self.path)
        if (m):
            status=int(m.group(1))
            # WHAT DOES NULL info.json look like?
            # https://github.com/IIIF/auth/issues/2
            self.api_version='2.0'
            i = IIIFInfo(api_version=self.api_version)
            i.identifier = 'abc'
            i.width = 0
            i.height = 0
            i.service = { '@context': 'http://example.org/auth_context.json',
                          '@id': "http://example.com/authn_here",
                          'label': "Authenticate here" }
            return self.send_json_response(json=i.as_json(),status=status)

        # Is this a request for a prefix index page?
        m = re.match(r'/([\w\._]+)$', self.path)
        if (m and m.group(1) in IIIFRequestHandler.MANIPULATORS):
            return self.send_prefix_index_page(m.group(1))

        # Is this a request for a test page?
        m = re.match(r'/([\w\._]+)$', self.path)
        if (m):
            page_path = os.path.join(IIIFRequestHandler.PAGES_DIR,m.group(1))
            if (os.path.isfile(page_path)):
                return self.send_html_file(page_path)

        # Now assume we have an iiif request
        m = re.match(r'/([\w\._]+)/(.*)$', self.path)
        if (m):
            self.prefix = m.group(1)
            self.path = m.group(2)
            if (self.prefix in IIIFRequestHandler.MANIPULATORS):
                self.api_version = IIIFRequestHandler.MANIPULATORS[self.prefix]['api_version']
                self.iiif = IIIFRequest(baseurl='/'+self.prefix+'/',api_version=self.api_version)
                self.manipulator = IIIFRequestHandler.MANIPULATORS[self.prefix]['klass'](api_version=self.api_version)
                self.auth_type = IIIFRequestHandler.MANIPULATORS[self.prefix]['auth_type']
            else:
                # 404 - unrecognized prefix
                self.send_404_response("Not Found - prefix /%s/ is not known" % (self.prefix))
                return
        else:
            # 404 - unrecognized path structure
            self.send_404_response("Not Found - path structure not recognized")
            return
        try:
            self.do_GET_body()
        except IIIFError as e:
            e.text += " Request parameters: "+str(self.iiif)
            self.write_error_response(e)
        except Exception as ue:
            # Anything else becomes a 500 Internal Server Error
            sys.stderr.write(str(ue)+"\n")
            self.write_error_response(IIIFError(code=500,text="Something went wrong... %s.\n"%(str(ue))))
開發者ID:edsu,項目名稱:iiif,代碼行數:69,代碼來源:iiif_testserver.py


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