move host, port and debug to server run function make .env variables writen in CAPS

This commit is contained in:
2024-04-13 01:22:54 +02:00
parent 4b179bc452
commit 0027476c4e
2 changed files with 11 additions and 13 deletions
+4 -6
View File
@@ -10,9 +10,7 @@ import logging, json, os
class Server:
default_snake_config = {"apiversion":"1","author":"","color":"#888888","head":"default","tail":"default"}
def __init__(self, data_path:str, snake:TemplateSnake, host:str="0.0.0.0", port:str="8000", debug:bool=False):
self.host = host
self.port = port
def __init__(self, data_path:str, snake:TemplateSnake, debug:bool=False):
self.debug = debug
self.snake = snake
@@ -50,11 +48,11 @@ class Server:
)
return response
def run(self):
def run(self, host:str="0.0.0.0", port:str="8000", debug:bool=False):
logging.getLogger("werkzeug").setLevel(logging.ERROR)
print(f"\nRunning Battlesnake at http://{self.host}:{self.port} with the {self.snake.__class__.__name__.replace('Snake', '')} Snake")
self.app.run(host=self.host, port=self.port, debug=self.debug)
print(f"\nRunning Battlesnake at http://{host}:{port} with the {self.snake.__class__.__name__.replace('Snake', '')} Snake")
self.app.run(host=host, port=port, debug=debug)
def _read_json_config_or_create(self):
snake_config = read_file(self.config_file, json.load)