zoukankan      html  css  js  c++  java
  • 前后端分离实现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);
  • 相关阅读:
    OAuth 2.0理论
    mvvm
    js中使用new所做的事情
    使用vue实现图片上传插件
    控制元素滚动位置
    float属性
    确定节点直接的关系
    react 开发中的问题简记
    深复制浅复制
    HTML和CSS实现常见的布局
  • 原文地址:https://www.cnblogs.com/qxh-beijing2016/p/12131830.html
Copyright © 2011-2022 走看看