Skip to content

Commit

Permalink
add getconf rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Mar 7, 2024
1 parent 71261be commit 0d68f96
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gamutrf/flask_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self, options, check_options, banned_args):
self.reconfigures = 0
self.app = Flask(__name__)
self.app.add_url_rule("/reconf", "reconf", self.reconf)
self.app.add_url_rule("/getconf", "getconf", self.getconf)
self.request = request
self.thread = threading.Thread(
target=self.app.run,
Expand All @@ -21,6 +22,14 @@ def __init__(self, options, check_options, banned_args):
def start(self):
self.thread.start()

def getconf(self):
return (
json.dumps(
{k: v for k, v in self.options.vars() if k not in self.banned_args}
),
200,
)

def reconf(self):
new_options = copy.deepcopy(self.options)
for arg, val in self.request.args.items():
Expand Down

0 comments on commit 0d68f96

Please sign in to comment.