Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/run_pyrit_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run_container(mode, tag="latest"):
"--name",
container_name,
"-p",
f"{port}:{port}",
f"127.0.0.1:{port}:{port}",
"-e",
f"PYRIT_MODE={mode}",
"-v",
Expand Down
2 changes: 1 addition & 1 deletion frontend/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def start_backend(*, config_file: str | None = None, initializers: list[str] | N
"-m",
"pyrit.cli.pyrit_backend",
"--host",
"0.0.0.0",
"localhost",
"--port",
"8000",
"--log-level",
Expand Down
2 changes: 1 addition & 1 deletion pyrit/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ The API will be available at `http://localhost:8000`
## Configuration

Environment variables:
- `PYRIT_API_HOST` - Host to bind to (default: 0.0.0.0)
- `PYRIT_API_HOST` - Host to bind to (default: localhost)
- `PYRIT_API_PORT` - Port to listen on (default: 8000)
- `PYRIT_API_RELOAD` - Enable auto-reload (default: false)
14 changes: 10 additions & 4 deletions pyrit/cli/pyrit_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def parse_args(*, args: Optional[list[str]] = None) -> Namespace:
# Start with custom port and host
pyrit_backend --host 0.0.0.0 --port 8080

# Expose to network (listen on all interfaces)
pyrit_backend --host 0.0.0.0

# List available initializers
pyrit_backend --list-initializers
""",
Expand All @@ -49,8 +52,8 @@ def parse_args(*, args: Optional[list[str]] = None) -> Namespace:
parser.add_argument(
"--host",
type=str,
default="0.0.0.0",
help="Host to bind the server to (default: 0.0.0.0)",
default="localhost",
help="Host to bind the server to (default: localhost)",
)

parser.add_argument(
Expand Down Expand Up @@ -196,8 +199,11 @@ async def initialize_and_run_async(*, parsed_args: Namespace) -> int:
default_labels["operation"] = context._operation
app.state.default_labels = default_labels

print(f"🚀 Starting PyRIT backend on http://{parsed_args.host}:{parsed_args.port}")
print(f" API Docs: http://{parsed_args.host}:{parsed_args.port}/docs")
display_host = parsed_args.host
print(f"🚀 Starting PyRIT backend on http://{display_host}:{parsed_args.port}")
print(f" API Docs: http://{display_host}:{parsed_args.port}/docs")
if parsed_args.host == "0.0.0.0":
print(f" Open in browser: http://localhost:{parsed_args.port}")

uvicorn_config = uvicorn.Config(
"pyrit.backend.main:app",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cli/test_pyrit_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_parse_args_defaults(self) -> None:
"""Should parse backend defaults correctly."""
args = pyrit_backend.parse_args(args=[])

assert args.host == "0.0.0.0"
assert args.host == "localhost"
assert args.port == 8000
assert args.config_file is None

Expand Down
Loading