Toloka2WebV2/app/api/config_api.py
CakesTwix af6a581f96
Fix torrent path
Need also update deps
2024-11-19 09:22:56 +02:00

25 lines
656 B
Python

from flask import jsonify
from app.services.torrents import initiate_config
from . import api_bp
@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)
@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})