import argparse
import functools
import os
import sys

from werkzeug.debug import DebuggedApplication
from werkzeug.serving import run_simple

from satosa.proxy_server import make_app
from satosa.satosa_config import SATOSAConfig

config_file = os.environ.get("SATOSA_CONFIG", "proxy_conf.yaml")
satosa_config = SATOSAConfig(config_file)
app = make_app(satosa_config)


def main():
    global app

    parser = argparse.ArgumentParser(description="Process some integers.")
    parser.add_argument("port", type=int)
    parser.add_argument("--keyfile", type=str)
    parser.add_argument("--certfile", type=str)
    parser.add_argument("--host", type=str)
    parser.add_argument(
        "-d", action='store_true', dest="debug", help="enable debug mode."
    )
    args = parser.parse_args()

    if (args.keyfile and not args.certfile) or (args.certfile and not args.keyfile):
        print("Both keyfile and certfile must be specified for HTTPS.")
        sys.exit()

    if args.debug:
        app.app = functools.partial(app.app, debug=True)
        app = DebuggedApplication(app)

    if (args.keyfile and args.certfile):
        ssl_context = (args.certfile, args.keyfile)
    else:
        ssl_context = None

    if args.host:
        run_simple(args.host, args.port, app, ssl_context=ssl_context)
    else:
        run_simple('localhost', args.port, app, ssl_context=ssl_context)


if __name__ == "__main__":
    main()

@@ -20,86 +20,22 @@
 ort 
-functools%0Aimport os%0Aimport sys%0A%0Afrom werkzeug.debug import DebuggedApplication
+os%0Aimport sys%0A
 %0Afro
@@ -587,114 +587,8 @@
 tr)%0A
-    parser.add_argument(%0A        %22-d%22, action='store_true', dest=%22debug%22, help=%22enable debug mode.%22%0A    )%0A
     
@@ -796,123 +796,8 @@
 ()%0A%0A
-    if args.debug:%0A        app.app = functools.partial(app.app, debug=True)%0A        app = DebuggedApplication(app)%0A
 %0A   

Remove debug middleware