Toloka2WebV2/app/api/config_api.py

26 lines
656 B
Python
Raw Normal View History

2024-09-23 12:15:53 -04:00
from flask import jsonify
from app.services.torrents import initiate_config
from . import api_bp
2024-09-23 12:17:25 -04:00
2024-09-23 12:15:53 -04:00
@api_bp.route("/api/config/")
def config_route():
config = initiate_config()
config = dict(config.app_config)
for section in config.keys():
config[section] = dict(config[section])
return jsonify(config)
2024-11-19 02:22:51 -05:00
@api_bp.route("/api/config/<section>/<element>/<value>")
def config_edit_route(section: str, element: str, value: str):
config = initiate_config()
config = config.app_config
config[section][element] = value
with open("data/app.ini", "w") as f:
config.write(f)
return jsonify({"result": True})