25 lines
656 B
Python
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})
|