Coverage for src/fastoai/cli.py: 0%

1 from typing import Annotated

2 from urllib.parse import urlparse

3

4 import typer

5 import uvicorn

6

7 from .dependencies import get_settings

8

9 app = typer.Typer()

10

11

12 result = urlparse(get_settings().base_url)

13 DEFAULT_HOST = result.hostname or "127.0.0.1"

14 DEFAULT_PORT = result.port or 8000

15

16

17@app.command()

18 def serve(

19 host: Annotated[

20 str, typer.Option(help="If not specified, will read from env FASTOAI_BASE_URL")

21 ] = DEFAULT_HOST,

22 port: Annotated[

23 int,

24 typer.Option(help="If not specified, will read from env FASTOAI_BASE_URL"),

25 ] = DEFAULT_PORT,

26 reload: bool = False,

27):

28 """Serve the FastAPI application."""

29 uvicorn.run(

30 "fastoai:app",

31 host=host,

32 port=port,

33 reload=reload,

34 reload_excludes=["generated/*.py"],

35 )