Skip to content

Commit 6bcd8d7

Browse files
committed
Update app.py
1 parent fb1f51c commit 6bcd8d7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/dynamic_user_interface_(htmx)/active_search/app.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def show_contacts(contacts: list[dict]):
3434
return [Tr(*[Td(contact[col]) for col in keys]) for contact in contacts]
3535

3636
# POST request to handle search
37-
@rt("/search")
38-
def post(search: str = None):
37+
@rt
38+
def search(search: str = None):
3939
# Default search term is empty string, which shows all contacts
4040
# If a search term is provided, it is converted to lowercase
4141
search_term = search.lower() if search else ""
@@ -52,7 +52,6 @@ def post(search: str = None):
5252
def index():
5353
return Titled("Active Search",
5454
Div(
55-
5655
H3("Search Contacts"),
5756
# HTMX for searching contacts
5857
Input(
@@ -63,7 +62,7 @@ def index():
6362
# Input is of a form type
6463
class_="form-control",
6564
# A POST request to '/search' is called when the user types
66-
hx_post="/search",
65+
post=search,
6766
# Search is delayed by 500ms to delay the search until the user has stopped typing
6867
# 'changed' is to ensure that no new search are triggered when the
6968
# user doesn't change the input of pastes the same value.

0 commit comments

Comments
 (0)