From 6db3fad9e32369200dc84dde7185afa85becae6c Mon Sep 17 00:00:00 2001 From: Bofh Date: Mon, 8 Feb 2021 21:16:06 +0100 Subject: [PATCH] Add API function to list mirrored accounts --- server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 6fac726..7697de4 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer import igmirror import sys +import os import re class MyServer(BaseHTTPRequestHandler): @@ -13,7 +14,12 @@ class MyServer(BaseHTTPRequestHandler): # example: /shakira/add path = self.path.strip('/') parts = path.split('/') - if len(parts) == 2: + if len(parts) == 1: + if parts[0] == 'list': + accounts = os.listdir('./db/accounts') + for acc in sorted(set(accounts)): + self.wfile.write(bytes(acc+'\n', "utf-8")) + elif len(parts) == 2: # a wilcard select all accounts if parts[0] == '*': if parts[1].lower() == 'update':