Skip to content

Commit 0b16f74

Browse files
committed
Remove port and host from pyproject.toml
1 parent 408e407 commit 0b16f74

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

src/fastapi_cli/cli.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ def _run(
122122
raise typer.Exit(code=1)
123123

124124
try:
125-
config = FastAPIConfig.resolve(
126-
host=host,
127-
port=port,
128-
entrypoint=entrypoint,
129-
)
125+
config = FastAPIConfig.resolve(entrypoint=entrypoint)
130126
except ValidationError as e:
131127
toolkit.print_line()
132128
toolkit.print("[error]Invalid configuration in pyproject.toml:")
@@ -183,7 +179,7 @@ def _run(
183179
tag="app",
184180
)
185181

186-
url = f"http://{config.host}:{config.port}"
182+
url = f"http://{host}:{port}"
187183
url_docs = f"{url}/docs"
188184

189185
toolkit.print_line()
@@ -211,8 +207,8 @@ def _run(
211207

212208
uvicorn.run(
213209
app=import_string,
214-
host=config.host,
215-
port=config.port,
210+
host=host,
211+
port=port,
216212
reload=reload,
217213
workers=workers,
218214
root_path=root_path,

src/fastapi_cli/config.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class FastAPIConfig(BaseModel):
1111
entrypoint: Optional[str] = None
12-
host: str = "127.0.0.1"
13-
port: int = 8000
1412

1513
@classmethod
1614
def _read_pyproject_toml(cls) -> Dict[str, Any]:
@@ -35,18 +33,9 @@ def _read_pyproject_toml(cls) -> Dict[str, Any]:
3533
return data.get("tool", {}).get("fastapi", {}) # type: ignore
3634

3735
@classmethod
38-
def resolve(
39-
cls,
40-
host: Optional[str] = None,
41-
port: Optional[int] = None,
42-
entrypoint: Optional[str] = None,
43-
) -> "FastAPIConfig":
36+
def resolve(cls, entrypoint: Optional[str] = None) -> "FastAPIConfig":
4437
config = cls._read_pyproject_toml()
4538

46-
if host is not None:
47-
config["host"] = host
48-
if port is not None:
49-
config["port"] = port
5039
if entrypoint is not None:
5140
config["entrypoint"] = entrypoint
5241

0 commit comments

Comments
 (0)