Skip to content

Commit 4dc533a

Browse files
committed
Define default port in constants file
1 parent 4e242bc commit 4dc533a

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

python-interpreter/packages/afm-core/src/afm/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import uvicorn
2828
from fastapi import FastAPI
2929

30+
from .constants import DEFAULT_HTTP_PORT
3031
from .exceptions import AFMError
3132
from .interfaces.base import get_http_path, get_interfaces
3233
from .interfaces.console_chat import async_run_console_chat
@@ -59,7 +60,7 @@ def create_unified_app(
5960
webhook_interface: WebhookInterface | None = None,
6061
startup_event: asyncio.Event | None = None,
6162
host: str = "0.0.0.0",
62-
port: int = 8085,
63+
port: int = DEFAULT_HTTP_PORT,
6364
) -> FastAPI:
6465
if webchat_interface is None and webhook_interface is None:
6566
raise ValueError("At least one HTTP interface must be provided")
@@ -348,9 +349,9 @@ def validate(file: Path) -> None:
348349
@click.option(
349350
"--port",
350351
"-p",
351-
default=8085,
352+
default=DEFAULT_HTTP_PORT,
352353
type=int,
353-
help="HTTP port for web interfaces (default: 8085)",
354+
help=f"HTTP port for web interfaces (default: {DEFAULT_HTTP_PORT})",
354355
)
355356
@click.option(
356357
"--host",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2+
#
3+
# WSO2 LLC. licenses this file to you under the Apache License,
4+
# Version 2.0 (the "License"); you may not use this file except
5+
# in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
# KIND, either express or implied. See the License for the
14+
# specific language governing permissions and limitations
15+
# under the License.
16+
17+
from __future__ import annotations
18+
19+
from typing import Final
20+
21+
DEFAULT_HTTP_PORT: Final = 8085

python-interpreter/packages/afm-core/src/afm/interfaces/webhook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from fastapi.responses import JSONResponse, PlainTextResponse
3030
from pydantic import BaseModel, Field
3131

32+
from ..constants import DEFAULT_HTTP_PORT
3233
from ..exceptions import TemplateEvaluationError
3334
from ..templates import compile_template, evaluate_template
3435
from .base import InterfaceNotFoundError, get_http_path, get_webhook_interface
@@ -375,7 +376,7 @@ def create_webhook_app(
375376
else:
376377
effective_host = "localhost"
377378

378-
effective_port = port if port else 8085
379+
effective_port = port if port else DEFAULT_HTTP_PORT
379380

380381
callback_url = f"http://{effective_host}:{effective_port}{webhook_path}"
381382
logger.warning(

0 commit comments

Comments
 (0)