Pass arguments to an app factory #1644
Replies: 3 comments
-
You can run |
Beta Was this translation helpful? Give feedback.
-
I've seen that page and it didn't appear to help as it doesn't demonstrate how to pass in arguments to an application factory function. |
Beta Was this translation helpful? Give feedback.
-
The answer is you can't. Simply because it's not supported. Line 440 in 3d26ab4 You need to use a workaround. In my case I used manual dependencies creation. Another solution could be using dependency injection via a DI package (like dependency-injector). Haven't tried it yet. |
Beta Was this translation helpful? Give feedback.
-
I'm wanting to pass the path to a configuration file to my server via the cli.
My code looks something like this:
Ie. the app the builds and configures itself.
I'm simply wanting to pass arguments to the factory method that uvicorn calls.
I don't want uvicorn to attempt to load or parse these arguments.
I've looked around the documentation and in regards to configuration it's very unclear on how to do this.
There is mention of a
--env-file
via cli, and the Config class supports anenv_file
argument.But both of these are parsed and somehow passed in.
I've already got a configuration file, I really don't want to write another one just as a way tell it to load the original.
How can I go about this?
Beta Was this translation helpful? Give feedback.
All reactions