当前位置: 首页>>代码示例>>Python>>正文


Python mimetypes.add_type方法代码示例

本文整理汇总了Python中mimetypes.add_type方法的典型用法代码示例。如果您正苦于以下问题:Python mimetypes.add_type方法的具体用法?Python mimetypes.add_type怎么用?Python mimetypes.add_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mimetypes的用法示例。


在下文中一共展示了mimetypes.add_type方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: app

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def app(environ, start_response):
    path_info = environ["PATH_INFO"]
    mimetypes.add_type('application/wasm', '.wasm')
    mimetypes.add_type('text/html', '.data')
    if path_info == '/':
        path_info = "/olapy.html"

    resource = "_build" + path_info
    headers = []
    headers.append(("Content-Type", mimetypes.guess_type(path_info.split("/")[-1])[0]))
    headers.append(('Access-Control-Allow-Origin', '*'))

    with open(resource, "rb") as f:
        resp_file = f.read()

    start_response("200 OK", headers)
    return [resp_file] 
开发者ID:abilian,项目名称:olapy,代码行数:19,代码来源:server.py

示例2: _fix_mime_types

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def _fix_mime_types(self):
        """Fix incorrect entries in the `mimetypes` registry.

        On Windows, the Python standard library's `mimetypes` reads in
        mappings from file extension to MIME type from the Windows
        registry. Other applications can and do write incorrect values
        to this registry, which causes `mimetypes.guess_type` to return
        incorrect values, which causes TensorBoard to fail to render on
        the frontend.

        This method hard-codes the correct mappings for certain MIME
        types that are known to be either used by TensorBoard or
        problematic in general.
        """
        # Known to be problematic when Visual Studio is installed:
        # <https://github.com/tensorflow/tensorboard/issues/3120>
        mimetypes.add_type("application/javascript", ".js")
        # Not known to be problematic, but used by TensorBoard:
        mimetypes.add_type("font/woff2", ".woff2")
        mimetypes.add_type("text/html", ".html") 
开发者ID:tensorflow,项目名称:tensorboard,代码行数:22,代码来源:program.py

示例3: imageMimeType

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def imageMimeType(path):

    # NOTE: add missing HDR mime type to python database
    if sys.version_info < (3, 0):
        mimetypes.add_type('image/vnd.radiance', '.hdr')

    mime = mimetypes.guess_type(path)[0]

    if mime in ['image/jpeg', 'image/bmp', 'image/vnd.radiance', 'image/png']:
        return mime
    else:
        return 'image/png' 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:14,代码来源:gltf.py

示例4: update_config

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def update_config(self, config):
        ''' Set up the resource library, public directory and
        template directory for all the spatial extensions
        '''
        p.toolkit.add_public_directory(config, 'public')
        p.toolkit.add_template_directory(config, 'templates')
        p.toolkit.add_resource('public', 'ckanext-spatial')

        # Add media types for common extensions not included in the mimetypes
        # module
        mimetypes.add_type('application/json', '.geojson')
        mimetypes.add_type('application/gml+xml', '.gml') 
开发者ID:italia,项目名称:daf-recipes,代码行数:14,代码来源:plugin.py

示例5: add_mime_types

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def add_mime_types(types):
    if not types:
        return
    for t in types.keys():
        for e in types[t]:
            mimetypes.add_type(type=t, ext=e if e.startswith(".") else "".join([".", e])) 
开发者ID:fair-research,项目名称:bdbag,代码行数:8,代码来源:__init__.py

示例6: _fix_mime_types

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def _fix_mime_types():
    """Fix incorrect entries in the `mimetypes` registry.
    On Windows, the Python standard library's `mimetypes` reads in
    mappings from file extension to MIME type from the Windows
    registry. Other applications can and do write incorrect values
    to this registry, which causes `mimetypes.guess_type` to return
    incorrect values, which causes TensorBoard to fail to render on
    the frontend.
    This method hard-codes the correct mappings for certain MIME
    types that are known to be either used by python-semantic-release or
    problematic in general.
    """
    mimetypes.add_type("text/markdown", ".md") 
开发者ID:relekang,项目名称:python-semantic-release,代码行数:15,代码来源:hvcs.py

示例7: initKnowMimetypes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def initKnowMimetypes():
    mimetypes.add_type("application/x-nes-rom", ".nes")
    mimetypes.add_type("application/x-snes-rom", ".sfc")
    mimetypes.add_type("application/x-gameboy-rom", ".gb")
    mimetypes.add_type("application/x-gbc-rom", ".gbc")
    mimetypes.add_type("application/x-genesis-rom" ,".md")
    mimetypes.add_type("application/x-megadrive-rom", ".md")
    mimetypes.add_type("application/x-genesis-rom" ,".32x")
    mimetypes.add_type("application/x-megadrive-rom", ".32x")

    mimetypes.add_type("application/x-sms-rom", ".sms")

    mimetypes.add_type("application/x-cd-image", ".bin")
    mimetypes.add_type("application/x-cd-image", ".chd")
    mimetypes.add_type("application/x-cd-image", ".cue")
    mimetypes.add_type("application/x-cd-image", ".pbp")


    mimetypes.add_type("application/x-ms-dos-executable", ".exe")
    mimetypes.add_type("application/x-ms-dos-executable", ".com")

    mimetypes.add_type("application/x-ms-dos-program", ".exe")
    mimetypes.add_type("application/x-ms-dos-program", ".com")

    mimetypes.add_type("application/x-ms-dos-batch", ".bat")


    mimetypes.add_type("application/x-gzip", ".zip")
    mimetypes.add_type("application/gzip", ".zip") 
开发者ID:JackD83,项目名称:PyMenu,代码行数:31,代码来源:OPKHelper.py

示例8: register_custom_mimetypes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def register_custom_mimetypes():
    mimetypes.add_type(b'text/x-csharp', b'.cs') 
开发者ID:indico,项目名称:indico-plugins,代码行数:4,代码来源:plugin.py

示例9: register_custom_mimetypes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def register_custom_mimetypes():
    mimetypes.add_type(b'application/x-ipynb+json', b'.ipynb') 
开发者ID:indico,项目名称:indico-plugins,代码行数:4,代码来源:plugin.py

示例10: add_mimetypes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def add_mimetypes():
    """
    Add extra mimetypes. Used in xblock_resource.

    If you add a mimetype here, be sure to also add it in lms/startup.py.
    """
    import mimetypes

    mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
    mimetypes.add_type('application/x-font-opentype', '.otf')
    mimetypes.add_type('application/x-font-ttf', '.ttf')
    mimetypes.add_type('application/font-woff', '.woff') 
开发者ID:jruiperezv,项目名称:ANALYSE,代码行数:14,代码来源:startup.py

示例11: init

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def init():
  mimetypes.add_type('application/dart', '.dart')
  mimetypes.add_type('text/css', '.gss')
  mimetypes.add_type('text/html', '.ng')
  mimetypes.add_type('application/x-font-ttf', '.ttf')
  mimetypes.add_type('application/font-woff', '.woff')
  mimetypes.add_type('application/font-woff2', '.woff2') 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:9,代码来源:augment_mimetypes.py

示例12: __init__

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def __init__(self, sample):
        self.sample = sample

        if not mimetypes.inited:
            mimetypes.init()
            mimetypes.add_type('application/javascript', '.jse') 
开发者ID:scVENUS,项目名称:PeekabooAV,代码行数:8,代码来源:file.py

示例13: _init_mimetypes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def _init_mimetypes(self):
        mimetypes.init()
        for missing_mime_type in self.MISSING_MIME_TYPES:
            mimetypes.add_type(missing_mime_type, self.MISSING_MIME_TYPES[missing_mime_type]) 
开发者ID:IllusiveNetworks-Labs,项目名称:WebTrap,代码行数:6,代码来源:PostProcessor.py

示例14: _init_mimes

# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import add_type [as 别名]
def _init_mimes(self):
        # add any custom, fixed mime types here
        mimetypes.add_type('image/x-icon', '.ico', True) 
开发者ID:webrecorder,项目名称:warcit,代码行数:5,代码来源:warcit.py


注:本文中的mimetypes.add_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。