Determine app module path correctly even when in a submodule. A bit cleaner dev options.

This commit is contained in:
2026-02-11 20:41:36 +00:00
parent cb6017cedf
commit 8b8a24a6b2
2 changed files with 7 additions and 5 deletions
+4 -2
View File
@@ -1347,13 +1347,15 @@ def cmd_setup(args: argparse.Namespace) -> int:
app_file, app_var = app_info
print(f"📍 Found FastAPI app: {app_var} in {app_file.name}")
tpl_vars["APP_VAR"] = app_var
tpl_vars["APP_MODULE"] = app_file.stem
# Dotted module path relative to project dir (e.g. "paskia.fastapi.mainapp")
app_module = ".".join(app_file.relative_to(project_dir).with_suffix("").parts)
tpl_vars["APP_MODULE"] = app_module
else:
print("📍 No existing FastAPI app found, will create new one")
app_file = None
app_var = "app"
tpl_vars["APP_VAR"] = app_var
tpl_vars["APP_MODULE"] = "app"
tpl_vars["APP_MODULE"] = f"{module_name}.app"
# Create directories
if not dry:
+3 -3
View File
@@ -17,12 +17,12 @@ def main():
help=(f"Endpoint (default: localhost:{DEFAULT_PORT})."),
)
args = parser.parse_args()
dev = {"reload": True, "reload_dirs": ["MODULE_NAME"]}
dev = {"reload": True, "reload_dirs": ["paskia"]} if DEVMODE else {}
server.run(
"MODULE_NAME.APP_MODULE:APP_VAR",
"APP_MODULE:APP_VAR",
listen=args.listen,
default_port=DEFAULT_PORT,
**(dev if DEVMODE else {}),
**dev,
)