Always show server location in ASGI
This commit is contained in:
parent
daa1f8f2d5
commit
f4c8252185
|
@ -69,6 +69,7 @@ else:
|
||||||
|
|
||||||
class RunnerMixin(metaclass=SanicMeta):
|
class RunnerMixin(metaclass=SanicMeta):
|
||||||
_app_registry: Dict[str, Sanic]
|
_app_registry: Dict[str, Sanic]
|
||||||
|
asgi: bool
|
||||||
config: Config
|
config: Config
|
||||||
listeners: Dict[str, List[ListenerType[Any]]]
|
listeners: Dict[str, List[ListenerType[Any]]]
|
||||||
state: ApplicationState
|
state: ApplicationState
|
||||||
|
@ -525,7 +526,7 @@ class RunnerMixin(metaclass=SanicMeta):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
server = ""
|
server = "ASGI" if self.asgi else "unknown"
|
||||||
|
|
||||||
display = {
|
display = {
|
||||||
"mode": " ".join(mode),
|
"mode": " ".join(mode),
|
||||||
|
@ -571,8 +572,12 @@ class RunnerMixin(metaclass=SanicMeta):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def serve_location(self) -> str:
|
def serve_location(self) -> str:
|
||||||
|
try:
|
||||||
server_settings = self.state.server_info[0].settings
|
server_settings = self.state.server_info[0].settings
|
||||||
return self.get_server_location(server_settings)
|
return self.get_server_location(server_settings)
|
||||||
|
except IndexError:
|
||||||
|
location = "ASGI" if self.asgi else "unknown"
|
||||||
|
return f"http://<{location}>"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_server_location(
|
def get_server_location(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user