From 8af923dc33211ddbc21ed5ec4a4a1155a8cf6b5d Mon Sep 17 00:00:00 2001 From: ngfchl Date: Wed, 4 Jan 2023 20:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=E5=A2=9E=E5=8A=A0HO?= =?UTF-8?q?STS=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto_pt/views.py | 15 +++++++++------ templates/auto_pt/settings.html | 7 ++++++- 2 files changed, 15 insertions(+), 7 deletions(-) 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 @@
+ + + +
@@ -46,6 +50,7 @@ data() { return { settings: '', + name: 'ptools.toml', } }, beforeMount() { @@ -57,7 +62,7 @@ methods: { get_config_settings() { axios.get( - "{% url 'get_config_api' %}" + "{% url 'get_config_api' %}" + '?name=' + this.name ).then(res => { console.log('获取数据列表成功', res) {#let data = res.data#}