Add 'api-port' setting to bot.conf and use it in rest_api.py

This commit is contained in:
jesopo 2019-03-13 16:52:51 +00:00
parent 6463bb16b5
commit 4058608bf2
2 changed files with 3 additions and 1 deletions

View file

@ -9,6 +9,7 @@ tls-certificate =
# key/cert used for REST API # key/cert used for REST API
tls-api-key = tls-api-key =
tls-api-certificate = tls-api-certificate =
api-port =
# the default channel BitBot automatically joins # the default channel BitBot automatically joins
bot-channel = bot-channel =

View file

@ -126,7 +126,8 @@ class Module(ModuleManager.BaseModule):
self.httpd = None self.httpd = None
if self.bot.get_setting("rest-api", False): if self.bot.get_setting("rest-api", False):
self.httpd = http.server.HTTPServer(("", 5000), Handler) port = int(self.bot.config.get("api-port", "5000"))
self.httpd = http.server.HTTPServer(("", port), Handler)
self.httpd.socket = utils.security.ssl_wrap(self.httpd.socket, self.httpd.socket = utils.security.ssl_wrap(self.httpd.socket,
cert=self.bot.config["tls-api-certificate"], cert=self.bot.config["tls-api-certificate"],