mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
Support of the --gradio-auth flag (#2283)
This commit is contained in:
parent
4155aaa96a
commit
7aed53559a
@ -279,6 +279,7 @@ Optionally, you can use the following command-line flags:
|
|||||||
| `--listen-port LISTEN_PORT` | The listening port that the server will use. |
|
| `--listen-port LISTEN_PORT` | The listening port that the server will use. |
|
||||||
| `--share` | Create a public URL. This is useful for running the web UI on Google Colab or similar. |
|
| `--share` | Create a public URL. This is useful for running the web UI on Google Colab or similar. |
|
||||||
| `--auto-launch` | Open the web UI in the default browser upon launch. |
|
| `--auto-launch` | Open the web UI in the default browser upon launch. |
|
||||||
|
| `--gradio-auth USER:PWD` | set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3" |
|
||||||
| `--gradio-auth-path GRADIO_AUTH_PATH` | Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3" |
|
| `--gradio-auth-path GRADIO_AUTH_PATH` | Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3" |
|
||||||
|
|
||||||
#### API
|
#### API
|
||||||
|
@ -164,6 +164,7 @@ parser.add_argument('--listen-host', type=str, help='The hostname that the serve
|
|||||||
parser.add_argument('--listen-port', type=int, help='The listening port that the server will use.')
|
parser.add_argument('--listen-port', type=int, help='The listening port that the server will use.')
|
||||||
parser.add_argument('--share', action='store_true', help='Create a public URL. This is useful for running the web UI on Google Colab or similar.')
|
parser.add_argument('--share', action='store_true', help='Create a public URL. This is useful for running the web UI on Google Colab or similar.')
|
||||||
parser.add_argument('--auto-launch', action='store_true', default=False, help='Open the web UI in the default browser upon launch.')
|
parser.add_argument('--auto-launch', action='store_true', default=False, help='Open the web UI in the default browser upon launch.')
|
||||||
|
parser.add_argument("--gradio-auth", type=str, help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"', default=None)
|
||||||
parser.add_argument("--gradio-auth-path", type=str, help='Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"', default=None)
|
parser.add_argument("--gradio-auth-path", type=str, help='Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"', default=None)
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
@ -543,11 +543,14 @@ def create_interface():
|
|||||||
|
|
||||||
# Authentication variables
|
# Authentication variables
|
||||||
auth = None
|
auth = None
|
||||||
|
gradio_auth_creds = []
|
||||||
|
if shared.args.gradio_auth:
|
||||||
|
gradio_auth_creds += [x.strip() for x in shared.args.gradio_auth.strip('"').replace('\n', '').split(',') if x.strip()]
|
||||||
if shared.args.gradio_auth_path is not None:
|
if shared.args.gradio_auth_path is not None:
|
||||||
gradio_auth_creds = []
|
|
||||||
with open(shared.args.gradio_auth_path, 'r', encoding="utf8") as file:
|
with open(shared.args.gradio_auth_path, 'r', encoding="utf8") as file:
|
||||||
for line in file.readlines():
|
for line in file.readlines():
|
||||||
gradio_auth_creds += [x.strip() for x in line.split(',') if x.strip()]
|
gradio_auth_creds += [x.strip() for x in line.split(',') if x.strip()]
|
||||||
|
if gradio_auth_creds:
|
||||||
auth = [tuple(cred.split(':')) for cred in gradio_auth_creds]
|
auth = [tuple(cred.split(':')) for cred in gradio_auth_creds]
|
||||||
|
|
||||||
# Importing the extension files and executing their setup() functions
|
# Importing the extension files and executing their setup() functions
|
||||||
|
Loading…
Reference in New Issue
Block a user