File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
examples/dynamic_user_interface_(htmx)/active_search Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ def show_contacts(contacts: list[dict]):
34
34
return [Tr (* [Td (contact [col ]) for col in keys ]) for contact in contacts ]
35
35
36
36
# POST request to handle search
37
- @rt ( "/search" )
38
- def post (search : str = None ):
37
+ @rt
38
+ def search (search : str = None ):
39
39
# Default search term is empty string, which shows all contacts
40
40
# If a search term is provided, it is converted to lowercase
41
41
search_term = search .lower () if search else ""
@@ -52,7 +52,6 @@ def post(search: str = None):
52
52
def index ():
53
53
return Titled ("Active Search" ,
54
54
Div (
55
-
56
55
H3 ("Search Contacts" ),
57
56
# HTMX for searching contacts
58
57
Input (
@@ -63,7 +62,7 @@ def index():
63
62
# Input is of a form type
64
63
class_ = "form-control" ,
65
64
# A POST request to '/search' is called when the user types
66
- hx_post = "/ search" ,
65
+ post = search ,
67
66
# Search is delayed by 500ms to delay the search until the user has stopped typing
68
67
# 'changed' is to ensure that no new search are triggered when the
69
68
# user doesn't change the input of pastes the same value.
You can’t perform that action at this time.
0 commit comments