| 243 | self._loaded_app: Quart | None = None |
| 244 | |
| 245 | def load_app(self) -> Quart: |
| 246 | if self._loaded_app is not None: |
| 247 | return self._loaded_app |
| 248 | |
| 249 | if self.create_app is not None: |
| 250 | app = self.create_app() |
| 251 | else: |
| 252 | if self.app_import_path: |
| 253 | path, name = ( |
| 254 | re.split(r":(?![\\/])", self.app_import_path, maxsplit=1) + [None] |
| 255 | )[:2] |
| 256 | import_name = prepare_import(path) |
| 257 | app = locate_app(import_name, name) |
| 258 | else: |
| 259 | import_name = prepare_import("app.py") |
| 260 | app = locate_app(import_name, None) |
| 261 | |
| 262 | if not app: |
| 263 | raise NoAppException( |
| 264 | "Could not locate a Quart application. Use the" |
| 265 | " 'quart --app' option, 'QUART_APP' environment" |
| 266 | " variable, or an 'app.py' file in the" |
| 267 | " current directory." |
| 268 | ) |
| 269 | |
| 270 | if self.set_debug_flag: |
| 271 | # Update the app's debug flag through the descriptor so that |
| 272 | # other values repopulate as well. |
| 273 | app.debug = get_debug_flag() |
| 274 | |
| 275 | self._loaded_app = app |
| 276 | return app |
| 277 | |
| 278 | |
| 279 | pass_script_info = click.make_pass_decorator(ScriptInfo, ensure=True) |