Add set_endpoint method to api.py

Better than writing to a global variable
This commit is contained in:
Peder Bergebakken Sundt 2018-03-02 18:35:10 +01:00
parent 4711246a40
commit 8ba98850d5
2 changed files with 5 additions and 2 deletions

5
api.py
View File

@ -3,8 +3,11 @@ from urllib.parse import urlencode
from functools import wraps from functools import wraps
import api 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" BASE_URL = "http://localhost:8080/api"
def set_endpoint(base_url:str):
global BASE_URL
BASE_URL = base_url
# Exceptions: # Exceptions:
class APIError(Exception): pass class APIError(Exception): pass

View File

@ -18,7 +18,7 @@ def main(config):
start_kwargs = {"standalone":config.standalone} start_kwargs = {"standalone":config.standalone}
# start the webserver: # start the webserver:
api.BASE_URL = config.api_base api.set_endpoint(config.api_base)
start( start(
gui.MyApp, gui.MyApp,
title = "Gregorz", title = "Gregorz",