Skip to content

fix: allow serve() to detect any entry point function name#829

Open
thecaptain789 wants to merge 1 commit intoAnswerDotAI:mainfrom
thecaptain789:fix-serve-detection
Open

fix: allow serve() to detect any entry point function name#829
thecaptain789 wants to merge 1 commit intoAnswerDotAI:mainfrom
thecaptain789:fix-serve-detection

Conversation

@thecaptain789
Copy link

Fixes #816.

The serve() function previously required the calling function to be named exactly 'main'. This restriction is unnecessary since the key check is whether we're running from __main__, not the function name.

Before: Entry points like myapp:start_app would fail silently.

After: Any function name works as long as it's called from __main__.

Changes:

  • Removed the code.co_name=='main' check from appname detection
  • Removed unused code variable

Fixes AnswerDotAI#816. The serve() function previously required the calling function
to be named exactly 'main'. This removes that restriction so entry points
with any name (e.g., 'start', 'run_app') work correctly.
@gitnotebooks
Copy link

gitnotebooks bot commented Feb 7, 2026

Review these changes at https://app.gitnotebooks.com/AnswerDotAI/fasthtml/pull/829

@jph00
Copy link
Contributor

jph00 commented Feb 15, 2026

This is an nbdev project so changes need to be made in the ipynb files, then exported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] serve() auto-detection fails silently if entry point function is not named main

2 participants