Conditionally inject CLI arguments into factory (#2402)

This commit is contained in:
Adam Hopkins
2022-03-23 12:00:41 +02:00
committed by GitHub
parent c9dbc8ed26
commit 0030425c8c
4 changed files with 57 additions and 16 deletions

View File

@@ -1,6 +0,0 @@
from sanic import Sanic
def run():
app = Sanic("FactoryTest")
return app

View File

@@ -34,3 +34,12 @@ async def shutdown(app: Sanic, _):
def create_app():
return app
def create_app_with_args(args):
try:
print(f"foo={args.foo}")
except AttributeError:
print(f"module={args.module}")
return app