diff --git a/.gitignore b/.gitignore index 405e1f2..75e3243 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.egg-info __pycache__ jigs/__version__.py +dist diff --git a/jigs/client.py b/jigs/client.py index e0a1271..11392c8 100755 --- a/jigs/client.py +++ b/jigs/client.py @@ -9,6 +9,7 @@ import io import json import re import subprocess +import urllib import httpx from PIL import Image @@ -59,8 +60,16 @@ unsafe_chars = re.compile(r"[^a-zA-Z0-9-_]+") default="firefox", help="Executable program to run on each image (e.g., open, firefox)", ) +@click.option( + "--url", + type=str, + envvar="JIGS_URL", + metavar="URL", + default="http://localhost:8072", + help="The URL of the server. Defaults to the content of the environment variable JIGS_URL. If JIGS_URL is unset, defaults to http://localhost:8072", +) @click.argument("qstr", nargs=-1, required=False) -def main(size, steps, action, negative_prompt, elaborate_instruction, qstr=[]): +def main(size, steps, action, negative_prompt, elaborate_instruction, url, qstr=[]): if qstr: prompt = " ".join(qstr) else: @@ -69,7 +78,7 @@ def main(size, steps, action, negative_prompt, elaborate_instruction, qstr=[]): width, height = map(int, size.split("x")) response = httpx.post( - "http://eric:8072/generate", + urllib.parse.urljoin(url, "generate"), data={ "prompt": prompt, "negative_prompt": negative_prompt, diff --git a/pyproject.toml b/pyproject.toml index 0f2da47..dc17c43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ repository = "https://github.com/jepler/jigs" [project.scripts] jigs-server = "jigs.server:main" -jigs-client = "jigs.client:main" +jigs = "jigs.client:main" [tool.setuptools_scm] write_to = "jigs/__version__.py"