Add set_endpoint method to api.py
Better than writing to a global variable
This commit is contained in:
parent
4711246a40
commit
8ba98850d5
5
api.py
5
api.py
|
@ -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
|
||||||
|
|
2
main.py
2
main.py
|
@ -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",
|
||||||
|
|
Loading…
Reference in New Issue