simple_file_server.py 文件源码

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

项目:Simple-File-Server 作者: RDCH106 项目源码 文件源码
def read_config():
    global settings
    global extensions_map
    exist = os.path.isfile(setting_file_name)
    if not exist:
        print 'Creating config file...'
        shutil.copyfile(default_setting_file_name, setting_file_name)
        print 'Edit config.json and launch the script again.'
        sys.exit()

    with open(setting_file_name) as data_file:
        settings = json.load(data_file)

        ####################################################################
        #Load default mimetypes and update them with config.json extensions#
        ####################################################################
        if not mimetypes.inited:
            mimetypes.init()  # try to read system mime.types
        extensions_map = mimetypes.types_map.copy()
        extensions_map.update({
            '': 'application/octet-stream'  # Default
        })
        extensions_map.update(settings['extensions'])  # Read extensions from config.json
        #####################################################################
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号