• 前后端分离实现django日志下载,celery日志下载


    djang后台:

    # django日志下载接口
    def django_journal_load(request):
        print BASE_DIR
        file = open(BASE_DIR + 'logsdjango.log', 'rb')
        response = StreamingHttpResponse(file.read())
        response['Content-Type'] = 'application/octet-stream'
        response['Content-Disposition'] = 'attachment;filename="{0}"'.format('django.log')
        return response
    
    
    # celery日志下载接口
    def celery_journal_load(request):
        file = open(os.getcwd() + '\..\task_centercelery.log', 'rb')
        response = StreamingHttpResponse(file.read())
        response['Content-Type'] = 'application/octet-stream'
        response['Content-Disposition'] = 'attachment;filename="{0}"'.format('celery.log')
        return response

    html前端:

    <dd><a href="" id="django_log">Django日志下载</a></dd>
    <dd><a href="" id="celery_log">Celery日志下载</a></dd>

    js

        var django_l=ip_number+"Django_journal_load";
        $("#django_log").attr("href",django_l);
        var celery_l=ip_number+"Celery_journal_load";
        $("#celery_log").attr("href",celery_l);
  • 相关阅读:
    python
    redis
    mongodb replica on aws ec2
    mysql
    java正则表达式
    终端make命令和Git学习
    linux和shell学习
    centos普通用户安装jenkins
    centos7普通用户安装jdk
    WPF动画
  • 原文地址:https://www.cnblogs.com/qxh-beijing2016/p/12131830.html
Copyright © 2020-2023  润新知