views.py 文件源码

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

项目:docker-grader 作者: elsys 项目源码 文件源码
def download(request, submission_id):
    submission = TaskSubmission.objects.get(pk=submission_id)
    file_name = '{0!s}_{1!s}_{2!s}'.format(submission.task.slug,
                                           submission.user.username,
                                           submission_id)
    path = smart_str(submission.get_submission_path())

    response = HttpResponse(content_type='application/force-download')
    response['Content-Disposition'] = 'attachment; filename={0!s}'.format(
        smart_str(file_name))
    response['X-Sendfile'] = path
    response['X-Accel-Redirect'] = get_submission_uri_from_path(path)
    return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号