From 345323390a416d83901a50a6697a735e3ff1c4b8 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Thu, 2 Apr 2020 23:48:46 -0500 Subject: [PATCH] Allow port configuration --- mercuryms.service | 1 + mms-download.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mercuryms.service b/mercuryms.service index 160d31e..b132660 100644 --- a/mercuryms.service +++ b/mercuryms.service @@ -5,6 +5,7 @@ After=network.target [Service] Type=simple ExecStart=/opt/mercuryms/bin/python /opt/mercuryms/mms-download.py +Environment="MERCURYMS_PORT=9092" [Install] WantedBy=multi-user.target diff --git a/mms-download.py b/mms-download.py index 352c861..86c2a3d 100644 --- a/mms-download.py +++ b/mms-download.py @@ -1,3 +1,4 @@ +import os import requests from flask import Flask, request from twilio.twiml.messaging_response import MessagingResponse @@ -18,4 +19,6 @@ def sms_reply(): return str(resp) if __name__ == '__main__': - app.run(host='0.0.0.0', port=9092, debug=True) + env_port = os.environ.get("MERCURYMS_PORT") + port = int(env_port) if env_port is not None else 9092 + app.run(host='0.0.0.0', port=port, debug=True) -- 2.20.1