diff --git a/api.py b/api.py index 909892d31798da82755493fb1b32a28835d30d42..72d91fec7697439148c6e3df2eed9f1dc2b59a08 100644 --- a/api.py +++ b/api.py @@ -9,6 +9,8 @@ from endpoints.send import Send from endpoints.token import Token from models.token import TokenModel +import os + token = TokenModel() token.setSecret() @@ -23,5 +25,7 @@ api.add_resource(Send, "/send") api.add_resource(Notify, "/notify") api.add_resource(Token, "/token") +flask_host = os.getenv("FLASK_HOST", "localhost") # Sets to whatever MQ_HOST is, or defaults to localhost + if __name__ == "__main__": - app.run(debug=False, port=8087, host="0.0.0.0") + app.run(debug=False, port=8087, host=flask_host) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index a76b1f7325892caa7b11dc3d8189a683ccf32853..ec86386a8c73796ade11eaed66f915468643418b 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -37,6 +37,7 @@ services: - rabbitmq__local environment: - MQ_HOST=rmq + - FLASK_HOST=0.0.0.0 volumes: - ../:/app command: "api.py" diff --git a/endpoints/token.py b/endpoints/token.py index 077ce5a81f66da6fcaa299f667e529749059980c..cbc1ec5f03a6aa0f93a5fce4f971795557364956 100644 --- a/endpoints/token.py +++ b/endpoints/token.py @@ -3,8 +3,6 @@ from flask_restful import Resource, request, abort from marshmallow import Schema, fields from models.token import TokenModel -import os - class TokenQuerySchema(Schema): client_id = fields.Str(required=True) secret = fields.Str(required=True) @@ -18,7 +16,6 @@ class Token(Resource): def __init__(self): self.schema = TokenQuerySchema() self.model = TokenModel() - data_dir = os.getenv("DATA_DIR", "/data") with open("./data/clients.json", "r") as clients_file: self.clients = json.load(clients_file)