Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,8 @@ class SearchApplication:
|
|
16 |
self.set_page_config()
|
17 |
|
18 |
st.header(self.title)
|
19 |
-
|
20 |
-
self.show_search_results()
|
21 |
|
22 |
-
self.query = st.text_input("Search", value="", key="search_query", on_change=self.show_search_results)
|
23 |
-
|
24 |
st.caption(
|
25 |
"This search toolkit is a user-friendly platform that enables efficient exploration and filtering of the comprehensive [Awesome Awesome Artificial Intelligence](https://github.com/zhimin-z/awesome-awesome-artificial-intelligence) list, which includes over 100 awesome lists about artificial intelligence, making it an indispensable resource for researchers, developers, and enthusiasts in the field."
|
26 |
)
|
@@ -34,26 +31,25 @@ class SearchApplication:
|
|
34 |
)
|
35 |
|
36 |
def show_search_results(self):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
st.write("No matches found.")
|
57 |
|
58 |
if __name__ == "__main__":
|
59 |
SearchApplication()
|
|
|
16 |
self.set_page_config()
|
17 |
|
18 |
st.header(self.title)
|
19 |
+
self.query = st.text_input("Search", value="", on_change=self.show_search_results)
|
|
|
20 |
|
|
|
|
|
21 |
st.caption(
|
22 |
"This search toolkit is a user-friendly platform that enables efficient exploration and filtering of the comprehensive [Awesome Awesome Artificial Intelligence](https://github.com/zhimin-z/awesome-awesome-artificial-intelligence) list, which includes over 100 awesome lists about artificial intelligence, making it an indispensable resource for researchers, developers, and enthusiasts in the field."
|
23 |
)
|
|
|
31 |
)
|
32 |
|
33 |
def show_search_results(self):
|
34 |
+
st.write("#")
|
35 |
+
|
36 |
+
readme_content = fetch_readme_content()
|
37 |
+
|
38 |
+
if readme_content:
|
39 |
+
search_results = []
|
40 |
+
lines = readme_content.split("\n")
|
41 |
+
for line in lines:
|
42 |
+
if self.query.lower() in line.lower():
|
43 |
+
search_results.append(line)
|
44 |
+
|
45 |
+
num_search_results = len(search_results)
|
46 |
+
st.write(f"A total of {num_search_results} matches found.")
|
47 |
+
|
48 |
+
if num_search_results > 0:
|
49 |
+
for result in search_results:
|
50 |
+
st.write(result)
|
51 |
+
else:
|
52 |
+
st.write("No matches found.")
|
|
|
53 |
|
54 |
if __name__ == "__main__":
|
55 |
SearchApplication()
|