diff --git a/config-example.py b/config-example.py index 51f3b9f..b1d7ddb 100644 --- a/config-example.py +++ b/config-example.py @@ -8,9 +8,6 @@ HOST = "127.0.0.1" # Port for development server to listen on PORT = 5000 -# File to store the JSON server list data in. -FILENAME = "list.json" - # Amount of time, is seconds, after which servers are removed from the list # if they haven't updated their listings. Note: By default Minetest servers # only announce once every 5 minutes, so this should be more than 300. diff --git a/server.py b/server.py index d51385f..2adba88 100755 --- a/server.py +++ b/server.py @@ -26,7 +26,7 @@ def index(): def list(): # We have to make sure that the list isn't cached, # since the list isn't really static. - return send_from_directory(app.static_folder, app.config["FILENAME"], + return send_from_directory(app.static_folder, "list.json", cache_timeout=0) @@ -336,7 +336,7 @@ class ServerList: def load(self): try: - with open(os.path.join("static", app.config["FILENAME"]), "r") as fd: + with open(os.path.join("static", "list.json"), "r") as fd: data = json.load(fd) except FileNotFoundError: return @@ -359,7 +359,7 @@ class ServerList: self.maxServers = max(servers, self.maxServers) self.maxClients = max(clients, self.maxClients) - with open(os.path.join("static", app.config["FILENAME"]), "w") as fd: + with open(os.path.join("static", "list.json"), "w") as fd: json.dump({ "total": {"servers": servers, "clients": clients}, "total_max": {"servers": self.maxServers, "clients": self.maxClients},