當前位置: 首頁>>代碼示例>>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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: _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

示例8: 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

示例9: 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

示例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;未經允許,請勿轉載。