logs.py 文件源码

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

项目:docklet 作者: unias 项目源码 文件源码
def get(*args, **kwargs):
        if ( ('user_group' in kwargs) == False):
            return {"success":'false', "reason":"Cannot get user_group"}
        user_group = kwargs['user_group']
        if (not ((user_group == 'admin') or (user_group == 'root'))):
            return {"success": 'false', "reason": 'Unauthorized Action'}
        filepath = logsPath + secure_filename(kwargs['filename'])
        try:
            if not os.path.exists(filepath):
                return {"success": 'false', "reason": 'file not exist'}
            logfile = open(filepath, 'r')
            logtext = logfile.read()
            logfile.close()
            return {'success': 'true', 'result': logtext}
        except:
            return {'success': 'false', 'reason': 'file read error'}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号