diff --git a/auto_pt/views.py b/auto_pt/views.py index 7c824f8..749ac72 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -1123,9 +1123,12 @@ def get_config_html(request): def save_config_api(request): - file_path = os.path.join(BASE_DIR, 'db/ptools.toml') content = json.loads(request.body.decode()) logger.info(content.get('settings')) + if content.get('name') == 'ptools.toml': + file_path = os.path.join(BASE_DIR, 'db/ptools.toml') + if content.get('name') == 'hosts': + file_path = '/etc/hosts' try: with open(file_path, 'w') as f: f.write(content.get('settings')) @@ -1133,8 +1136,9 @@ def save_config_api(request): msg='配置文件保存成功!' ).to_dict(), safe=False) except Exception as e: + raise return JsonResponse(data=CommonResponse.error( - msg='获取配置文件信息失败!' + msg=f'获取配置文件信息失败!{e}' ).to_dict(), safe=False) diff --git a/templates/auto_pt/settings.html b/templates/auto_pt/settings.html index 7b5ca59..7595597 100644 --- a/templates/auto_pt/settings.html +++ b/templates/auto_pt/settings.html @@ -8,18 +8,34 @@