2727class Things3API ():
2828 """API Wrapper for the simple read-only API for Things 3."""
2929
30- HOST = 'localhost'
31- PORT = 15000
3230 PATH = getcwd () + '/resources/'
3331 things3 = None
3432 test_mode = "task"
33+ host = 'localhost'
34+ port = 15000
3535
3636 def on_get (self , url ):
3737 """Handles other GET requests"""
@@ -100,7 +100,12 @@ def api_filter_reset(self):
100100 self .things3 .filter = ""
101101 return Response (status = 200 )
102102
103- def __init__ (self , database = None ):
103+ def __init__ (self , database = None , host = None , port = None ):
104+ cfg = Things3 .get_from_config (Things3 .config , host , 'KANBANVIEW_HOST' )
105+ self .host = cfg if cfg else self .host
106+ cfg = Things3 .get_from_config (Things3 .config , port , 'KANBANVIEW_PORT' )
107+ self .port = cfg if cfg else self .port
108+
104109 self .things3 = Things3 (database = database )
105110 self .flask = Flask (__name__ )
106111 self .flask .add_url_rule ('/api/<command>' , view_func = self .api )
@@ -114,11 +119,11 @@ def __init__(self, database=None):
114119
115120 def main (self ):
116121 """"Main function."""
117- print (f"Serving at http://{ self .HOST } :{ self .PORT } ..." )
122+ print (f"Serving at http://{ self .host } :{ self .port } ..." )
118123
119124 try :
120125 self .flask_context = make_server (
121- self .HOST , self .PORT , self .flask , True )
126+ self .host , self .port , self .flask , True )
122127 self .flask_context .serve_forever ()
123128 except KeyboardInterrupt :
124129 print ("Shutting down..." )
0 commit comments