From 9e3738b516a4b997ae351ad8a43ca3b889dc9004 Mon Sep 17 00:00:00 2001 From: Maksim Kondratev Date: Wed, 3 Feb 2021 19:15:12 +0300 Subject: [PATCH] Added load_asgi_app method to CLI class --- daphne/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daphne/cli.py b/daphne/cli.py index 8c42c43..a51051c 100755 --- a/daphne/cli.py +++ b/daphne/cli.py @@ -200,6 +200,12 @@ class CommandLineInterface(object): if args.proxy_headers: return "X-Forwarded-Port" + def load_asgi_app(self, asgi_app_path: str): + """ + Return the imported application. + """ + return import_by_path(asgi_app_path) + def run(self, args): """ Pass in raw argument list and it will decode them @@ -229,7 +235,7 @@ class CommandLineInterface(object): # Import application sys.path.insert(0, ".") - application = import_by_path(args.application) + application = self.load_asgi_app(args.application) application = guarantee_single_callable(application) # Set up port/host bindings