Always show server location in ASGI (#2522)
Co-authored-by: Adam Hopkins <adam@amhopkins.com> Co-authored-by: Zhiwei Liang <zhi.wei.liang@outlook.com> Co-authored-by: Néstor Pérez <25409753+prryplatypus@users.noreply.github.com>
This commit is contained in:
@@ -525,7 +525,7 @@ class RunnerMixin(metaclass=SanicMeta):
|
||||
)
|
||||
)
|
||||
else:
|
||||
server = ""
|
||||
server = "ASGI" if self.asgi else "unknown" # type: ignore
|
||||
|
||||
display = {
|
||||
"mode": " ".join(mode),
|
||||
@@ -571,8 +571,12 @@ class RunnerMixin(metaclass=SanicMeta):
|
||||
|
||||
@property
|
||||
def serve_location(self) -> str:
|
||||
server_settings = self.state.server_info[0].settings
|
||||
return self.get_server_location(server_settings)
|
||||
try:
|
||||
server_settings = self.state.server_info[0].settings
|
||||
return self.get_server_location(server_settings)
|
||||
except IndexError:
|
||||
location = "ASGI" if self.asgi else "unknown" # type: ignore
|
||||
return f"http://<{location}>"
|
||||
|
||||
@staticmethod
|
||||
def get_server_location(
|
||||
|
||||
Reference in New Issue
Block a user