mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
新增 下载日志功能
This commit is contained in:
@@ -32,6 +32,7 @@ urlpatterns = [
|
||||
path(r'get_log_list', views.get_log_list, name='get_log_list'),
|
||||
path(r'show_log_list', views.show_log_list, name='show_log_list'),
|
||||
path(r'get_log_content', views.get_log_content, name='get_log_content'),
|
||||
path(r'download_log_file', views.download_log_file, name='download_log_file'),
|
||||
path(r'remove_log_api', views.remove_log_api, name='remove_log_api'),
|
||||
path(r'get_site_list', views.get_site_list, name='get_site_list'),
|
||||
path(r'edit_my_site', views.edit_my_site, name='edit_my_site'),
|
||||
|
||||
@@ -11,7 +11,7 @@ import git
|
||||
import qbittorrentapi
|
||||
import transmission_rpc
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import JsonResponse
|
||||
from django.http import JsonResponse, FileResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
from pt_site.UtilityTool import MessageTemplate, FileSizeConvert
|
||||
@@ -922,6 +922,20 @@ def remove_log_api(request):
|
||||
).to_dict(), safe=False)
|
||||
|
||||
|
||||
def download_log_file(request):
|
||||
try:
|
||||
name = request.GET.get('name')
|
||||
file_path = os.path.join(BASE_DIR, f'db/{name}')
|
||||
response = FileResponse(open(file_path, 'rb'))
|
||||
response['content-type'] = "application/octet-stream;charset=utf-8"
|
||||
response['Content-Disposition'] = 'attachment; filename=' + os.path.basename(file_path)
|
||||
return response
|
||||
except Exception as e:
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg=f'文件不存在?!{e}'
|
||||
).to_dict(), safe=False)
|
||||
|
||||
|
||||
def show_log_list(request):
|
||||
return render(request, 'auto_pt/showlog.html')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user