diff --git a/auto_pt/views.py b/auto_pt/views.py index 7930c63..7c824f8 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -1096,12 +1096,15 @@ def get_site_torrents(request): def get_config_api(request): - file_path = os.path.join(BASE_DIR, 'db/ptools.toml') - res = pt_spider.generate_config_file() - if res.code != 0: - return JsonResponse(data=CommonResponse.error( - msg=res.msg - ).to_dict(), safe=False) + if request.GET.get('name') == 'ptools.toml': + file_path = os.path.join(BASE_DIR, 'db/ptools.toml') + res = pt_spider.generate_config_file() + if res.code != 0: + return JsonResponse(data=CommonResponse.error( + msg=res.msg + ).to_dict(), safe=False) + if request.GET.get('name') == 'hosts': + file_path = '/etc/hosts' try: with open(file_path, 'rb') as f: response = HttpResponse(f) diff --git a/templates/auto_pt/settings.html b/templates/auto_pt/settings.html index 8524c44..7b5ca59 100644 --- a/templates/auto_pt/settings.html +++ b/templates/auto_pt/settings.html @@ -33,6 +33,10 @@