PortalServer.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:jumpscale_portal 作者: jumpscale7 项目源码 文件源码
def getMimeType(self, contenttype, format_types, result=None):
        supported_types = ["text/plain", "text/html", "application/yaml", "application/json"]
        CONTENT_TYPES = {
            "text/plain": str,
            "text/html": self._text2htmlSerializer,
            "application/yaml": self._resultyamlSerializer,
            "application/json": j.db.serializers.getSerializerType('j').dumps
        }

        if not contenttype:
            serializer = format_types["text"]["serializer"]
            return CONTENT_TYPE_HTML, serializer
        elif isinstance(result, types.GeneratorType):
            return 'application/octet-stream', lambda x: x
        else:
            mimeType = mimeparse.best_match(supported_types, contenttype)
            serializer = CONTENT_TYPES[mimeType]
            return mimeType, serializer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号