Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reload_includes and reload_excludes options to serve #291

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions fasthtml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,10 @@ def serve(
app='app', # App instance to be served
host='0.0.0.0', # If host is 0.0.0.0 will convert to localhost
port=None, # If port is None it will default to 5001 or the PORT environment variable
reload=True): # Default is to reload the app upon code changes
reload=True, # Default is to reload the app upon code changes
reload_includes:list[str]|str|None=None, # Additional files to watch for changes
reload_excludes:list[str]|str|None=None # Files to ignore for changes
):
"Run the app in an async server, with live reload set as the default."
bk = inspect.currentframe().f_back
glb = bk.f_globals
Expand All @@ -510,7 +513,7 @@ def serve(
if appname:
if not port: port=int(os.getenv("PORT", default=5001))
print(f'Link: http://{"localhost" if host=="0.0.0.0" else host}:{port}')
uvicorn.run(f'{appname}:{app}', host=host, port=port, reload=reload)
uvicorn.run(f'{appname}:{app}', host=host, port=port, reload=reload, reload_includes=reload_includes, reload_excludes=reload_excludes)

# %% ../nbs/api/00_core.ipynb
def cookie(key: str, value="", max_age=None, expires=None, path="/", domain=None, secure=False, httponly=False, samesite="lax",):
Expand Down
7 changes: 5 additions & 2 deletions nbs/api/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,10 @@
" app='app', # App instance to be served\n",
" host='0.0.0.0', # If host is 0.0.0.0 will convert to localhost\n",
" port=None, # If port is None it will default to 5001 or the PORT environment variable\n",
" reload=True): # Default is to reload the app upon code changes\n",
" reload=True, # Default is to reload the app upon code changes\n",
" reload_includes:list[str]|str|None=None, # Additional files to watch for changes\n",
" reload_excludes:list[str]|str|None=None # Files to ignore for changes\n",
" ): \n",
" \"Run the app in an async server, with live reload set as the default.\"\n",
" bk = inspect.currentframe().f_back\n",
" glb = bk.f_globals\n",
Expand All @@ -1212,7 +1215,7 @@
" if appname:\n",
" if not port: port=int(os.getenv(\"PORT\", default=5001))\n",
" print(f'Link: http://{\"localhost\" if host==\"0.0.0.0\" else host}:{port}')\n",
" uvicorn.run(f'{appname}:{app}', host=host, port=port, reload=reload)"
" uvicorn.run(f'{appname}:{app}', host=host, port=port, reload=reload, reload_includes=reload_includes, reload_excludes=reload_excludes)"
]
},
{
Expand Down
Loading