Update app.py
Browse files
app.py
CHANGED
@@ -16,19 +16,15 @@ class SearchApplication:
|
|
16 |
self.set_page_config()
|
17 |
|
18 |
st.header(self.title)
|
19 |
-
|
20 |
-
with col1:
|
21 |
-
self.query = st.text_input("Search", value="", on_change=self.show_search_results)
|
22 |
-
|
23 |
-
with col2:
|
24 |
-
st.write("#")
|
25 |
-
self.search_button = st.button("🔎", on_click=self.show_search_results)
|
26 |
|
27 |
st.caption(
|
28 |
"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."
|
29 |
)
|
30 |
st.write("#")
|
31 |
|
|
|
|
|
32 |
def set_page_config(self):
|
33 |
st.set_page_config(
|
34 |
page_title=self.title,
|
@@ -37,26 +33,26 @@ class SearchApplication:
|
|
37 |
)
|
38 |
|
39 |
def show_search_results(self):
|
40 |
-
|
41 |
-
|
42 |
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
SearchApplication()
|
|
|
16 |
self.set_page_config()
|
17 |
|
18 |
st.header(self.title)
|
19 |
+
self.query = st.text_input("Search", value="")
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
)
|
24 |
st.write("#")
|
25 |
|
26 |
+
self.show_search_results()
|
27 |
+
|
28 |
def set_page_config(self):
|
29 |
st.set_page_config(
|
30 |
page_title=self.title,
|
|
|
33 |
)
|
34 |
|
35 |
def show_search_results(self):
|
36 |
+
if self.query:
|
37 |
+
st.write("#")
|
38 |
|
39 |
+
readme_content = fetch_readme_content()
|
40 |
|
41 |
+
if readme_content:
|
42 |
+
search_results = []
|
43 |
+
lines = readme_content.split("\n")
|
44 |
+
for line in lines:
|
45 |
+
if self.query.lower() in line.lower():
|
46 |
+
search_results.append(line)
|
47 |
|
48 |
+
num_search_results = len(search_results)
|
49 |
+
st.write(f"A total of {num_search_results} matches found.")
|
50 |
|
51 |
+
if num_search_results > 0:
|
52 |
+
for result in search_results:
|
53 |
+
st.write(result)
|
54 |
+
else:
|
55 |
+
st.write("No matches found.")
|
56 |
|
57 |
if __name__ == "__main__":
|
58 |
SearchApplication()
|