From 8ba98850d5034225fbad937133b594ee639df8ac Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 2 Mar 2018 18:35:10 +0100 Subject: [PATCH] Add set_endpoint method to api.py Better than writing to a global variable --- api.py | 5 ++++- main.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index 0b27dc5..a955b62 100644 --- a/api.py +++ b/api.py @@ -3,8 +3,11 @@ from urllib.parse import urlencode from functools import wraps import api -# This will be overwritten by config +# This must be set to be able to use it on remote hosts BASE_URL = "http://localhost:8080/api" +def set_endpoint(base_url:str): + global BASE_URL + BASE_URL = base_url # Exceptions: class APIError(Exception): pass diff --git a/main.py b/main.py index 1f0fb28..d654fb9 100755 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ def main(config): start_kwargs = {"standalone":config.standalone} # start the webserver: - api.BASE_URL = config.api_base + api.set_endpoint(config.api_base) start( gui.MyApp, title = "Gregorz",