File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change
1
+ import importlib
1
2
from logging import getLogger
2
3
from pathlib import Path
3
4
from typing import Any , Union
@@ -45,6 +46,13 @@ def callback(
45
46
"""
46
47
47
48
49
+ def _get_docs_url (uvicorn_path : str ) -> str :
50
+ module_path , app_name = uvicorn_path .split (sep = ":" )
51
+ module = importlib .import_module (module_path )
52
+ app = getattr (module , app_name )
53
+ return app .docs_url
54
+
55
+
48
56
def _run (
49
57
path : Union [Path , None ] = None ,
50
58
* ,
@@ -62,7 +70,13 @@ def _run(
62
70
except FastAPICLIException as e :
63
71
logger .error (str (e ))
64
72
raise typer .Exit (code = 1 ) from None
65
- serving_str = f"[dim]Serving at:[/dim] [link]http://{ host } :{ port } [/link]\n \n [dim]API docs:[/dim] [link]http://{ host } :{ port } /docs[/link]"
73
+
74
+ docs_url = _get_docs_url (use_uvicorn_app )
75
+
76
+ serving_str = (
77
+ f"[dim]Serving at:[/dim] [link]http://{ host } :{ port } [/link]\n \n [dim]"
78
+ f"API docs:[/dim] [link]http://{ host } :{ port } { docs_url } [/link]"
79
+ )
66
80
67
81
if command == "dev" :
68
82
panel = Panel (
You can’t perform that action at this time.
0 commit comments