Adds API HOST and PORT as configurable parameters.

Uses API_BIND/API_PORT for the server and API_CONNECT/API_PORT for the user, for consistency.
This commit is contained in:
Sergi Delgado Segura
2020-04-07 12:10:49 +02:00
parent 2be433d589
commit bed21e9625
13 changed files with 50 additions and 31 deletions

View File

@@ -3,8 +3,8 @@ import logging
from math import ceil
from flask import Flask, request, abort, jsonify
from teos import LOG_PREFIX
import teos.errors as errors
from teos import HOST, PORT, LOG_PREFIX
from teos.inspector import InspectionFailed
from teos.gatekeeper import NotEnoughSlots, IdentificationFailure
@@ -79,7 +79,9 @@ class API:
access.
"""
def __init__(self, inspector, watcher, gatekeeper):
def __init__(self, host, port, inspector, watcher, gatekeeper):
self.host = host
self.port = port
self.inspector = inspector
self.watcher = watcher
self.gatekeeper = gatekeeper
@@ -341,4 +343,4 @@ class API:
logging.getLogger("werkzeug").setLevel(logging.ERROR)
os.environ["WERKZEUG_RUN_MAIN"] = "true"
app.run(host=HOST, port=PORT)
app.run(host=self.host, port=self.port)