说明
需要通过后台直接周期任务运行的结果日志,这样就不需要每次登录服务器。
代码
接口代码
def getlog(request):
    '''
    日志查看
    '''
    if request.method == 'GET':
        logpath = request.GET.get('path', default='')
        content = '无日志'
        if os.path.exists(logpath):
            with open(logpath, 'r') as f:
                content = f.read()
        return render(request, 'logview.html', {'logpath': logpath, 'content': content})模板文件
{% block content %}
<h2>{{ logpath }}</h2>
<div style="background-color: black;color: azure" >
    <span  style="font-size: 10px"><pre>{{ content }}  </pre>
</div>
{% endblock %}            
        
            
                        
                        
                        
                    
                    
                    
                    
评论 (0)