当前位置: 首页>>代码示例>>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;未经允许,请勿转载。