|
34 | 34 | import modules.hypernetworks.hypernetwork |
35 | 35 |
|
36 | 36 | queue_lock = threading.Lock() |
37 | | - |
| 37 | +server_name = "0.0.0.0" if cmd_opts.listen else cmd_opts.server_name |
38 | 38 |
|
39 | 39 | def wrap_queued_call(func): |
40 | 40 | def f(*args, **kwargs): |
@@ -85,6 +85,20 @@ def initialize(): |
85 | 85 | shared.opts.onchange("sd_hypernetwork", wrap_queued_call(lambda: modules.hypernetworks.hypernetwork.load_hypernetwork(shared.opts.sd_hypernetwork))) |
86 | 86 | shared.opts.onchange("sd_hypernetwork_strength", modules.hypernetworks.hypernetwork.apply_strength) |
87 | 87 |
|
| 88 | + if cmd_opts.tls_keyfile is not None and cmd_opts.tls_keyfile is not None: |
| 89 | + |
| 90 | + try: |
| 91 | + if not os.path.exists(cmd_opts.tls_keyfile): |
| 92 | + print("Invalid path to TLS keyfile given") |
| 93 | + if not os.path.exists(cmd_opts.tls_certfile): |
| 94 | + print(f"Invalid path to TLS certfile: '{cmd_opts.tls_certfile}'") |
| 95 | + except TypeError: |
| 96 | + cmd_opts.tls_keyfile = cmd_opts.tls_certfile = None |
| 97 | + print("TLS setup invalid, running webui without TLS") |
| 98 | + else: |
| 99 | + print("Running with TLS") |
| 100 | + |
| 101 | + |
88 | 102 | # make the program just exit at ctrl+c without waiting for anything |
89 | 103 | def sigint_handler(sig, frame): |
90 | 104 | print(f'Interrupted with signal {sig} in {frame}') |
@@ -131,8 +145,10 @@ def webui(): |
131 | 145 |
|
132 | 146 | app, local_url, share_url = demo.launch( |
133 | 147 | share=cmd_opts.share, |
134 | | - server_name="0.0.0.0" if cmd_opts.listen else None, |
| 148 | + server_name=server_name, |
135 | 149 | server_port=cmd_opts.port, |
| 150 | + ssl_keyfile=cmd_opts.tls_keyfile, |
| 151 | + ssl_certfile=cmd_opts.tls_certfile, |
136 | 152 | debug=cmd_opts.gradio_debug, |
137 | 153 | auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None, |
138 | 154 | inbrowser=cmd_opts.autolaunch, |
|
0 commit comments