diff --git a/main.py b/main.py
index 2ffca261f9b228af0ca080c30476ebdf31513a93..30d32762284dca7e311d8725b55696c71169a2aa 100644
--- a/main.py
+++ b/main.py
@@ -1,4 +1,10 @@
-# Example of minimal working WSGI script
+#!/usr/bin/env python3
+import sys
+from datetime import datetime
+import os.path
+import re
+import subprocess
+
 from flask import Flask, render_template, request, make_response, redirect, flash
 from flask_wtf import FlaskForm
 from wtforms import StringField
@@ -7,11 +13,6 @@ from wtforms.validators import DataRequired, Email
 import requests
 import yaml
 
-from datetime import datetime
-import os.path
-import re
-import subprocess
-
 app = Flask(__name__)
 app.secret_key = "ASDF1234 - CHANGE ME!"
 
@@ -26,14 +27,15 @@ def load_config():
     """Load various variables, api keys, etc. and set configuration parameters"""
     global SOCTOOLSPROXY, KEYCLOAK_BASE_URL, KEYCLOAK_ADMIN_PASSWORD
     variables = yaml.safe_load(open(VARIABLES_FILE, "r"))
-    print(variables)
     # Get FQDN of the main server
     SOCTOOLSPROXY = variables["soctoolsproxy"]
     assert re.match('[a-zA-Z0-9.-]+', SOCTOOLSPROXY), f"ERROR: The 'soctoolsproxy' variable loaded from '{VARIABLES_FILE}' is not a valid domain name."
     # Set base URL to Keycloak
     KEYCLOAK_BASE_URL = f"https://{SOCTOOLSPROXY}:12443"
     # Load API key for Keycloak
-    KEYCLOAK_ADMIN_PASSWORD = open(KEYCLOAK_ADMIN_PASSWORD_FILE, "r").read(100) # read max 100 B, the key should never be so long
+    KEYCLOAK_ADMIN_PASSWORD = open(KEYCLOAK_ADMIN_PASSWORD_FILE, "r").read(100).strip() # read max 100 B, the key should never be so long
+    print(f"Config loaded:\nSOCTOOLSPROXY={SOCTOOLSPROXY}\nKEYCLOAK_BASE_URL={KEYCLOAK_BASE_URL}\n"
+          f"KEYCLOAK_ADMIN_PASSWORD={KEYCLOAK_ADMIN_PASSWORD[:3]}...{KEYCLOAK_ADMIN_PASSWORD[-4:]}")
 
 
 # *** Custom Jinja filters ***
@@ -105,7 +107,7 @@ def main():
     if form_add_user.validate_on_submit():
         # TODO check that username doesn't exist, yet (and check validity, i.e. special characters etc.)
         # TODO add user
-        result = subprocess.run(["echo", "test"], capture_output=True)
+        result = subprocess.run(["echo", "test"])
         if result.returncode == 0:
             flash(f'User "{form_add_user.username.data}" successfully created.', "success")
         else:
@@ -122,5 +124,12 @@ def main():
 
 
 # When the script is run directly, run the application on a local development server.
+# Optionally pass two parameters, 'host' (IP to listen on) and 'port',
+# e.g.: ./main.py 0.0.0.0 8080
 if __name__ == '__main__':
-    app.run()
+    host, port = '127.0.0.1', 5000 # defaults
+    if len(sys.argv) > 2:
+        host = sys.argv[1]
+        port = int(sys.argv[2])
+    app.config['ENV'] = 'development'
+    app.run(host=host, port=port, debug=True)
diff --git a/requirements.txt b/requirements.txt
index 532a5a094918a68ac7ed7d41155563c650640ae9..5ce796c5eed5668c22e6d3d7d6aa7479cf255856 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,8 @@
-flask~=2.1.0
-flask_wtf~=1.0.0
-wtforms~=3.0.1
+flask~=2.0.3
+flask_wtf~=1.0.1
+wtforms~=3.0.0
 email-validator~=1.1.3
 requests~=2.27.1
-jinja2~=3.1.1
-PyYAML~=5.2
\ No newline at end of file
+jinja2~=3.0.3
+PyYAML~=6.0
+gunicorn~=20.1.0