Update app.py
Browse files
app.py
CHANGED
@@ -10,30 +10,6 @@ def fetch_readme_content():
|
|
10 |
st.error("Failed to fetch README.md content from GitHub.")
|
11 |
return ""
|
12 |
|
13 |
-
def show_search_results():
|
14 |
-
query = st.session_state.query
|
15 |
-
|
16 |
-
if query:
|
17 |
-
st.write("#")
|
18 |
-
|
19 |
-
readme_content = fetch_readme_content()
|
20 |
-
|
21 |
-
if readme_content:
|
22 |
-
search_results = []
|
23 |
-
lines = readme_content.split("\n")
|
24 |
-
for line in lines:
|
25 |
-
if query.lower() in line.lower():
|
26 |
-
search_results.append(line)
|
27 |
-
|
28 |
-
num_search_results = len(search_results)
|
29 |
-
st.write(f"A total of {num_search_results} matches found.")
|
30 |
-
|
31 |
-
if num_search_results > 0:
|
32 |
-
for result in search_results:
|
33 |
-
st.write(result)
|
34 |
-
else:
|
35 |
-
st.write("No matches found.")
|
36 |
-
|
37 |
class SearchApplication:
|
38 |
def __init__(self):
|
39 |
self.title = "Awesome Awesome Artificial Intelligence Search"
|
@@ -42,19 +18,14 @@ class SearchApplication:
|
|
42 |
st.header(self.title)
|
43 |
col1, col2 = st.columns(2)
|
44 |
with col1:
|
45 |
-
st.text_input("Search", value="",
|
46 |
-
|
47 |
-
with col2:
|
48 |
-
st.write("#")
|
49 |
-
# No need for search button since we're updating in real-time
|
50 |
|
51 |
st.caption(
|
52 |
"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."
|
53 |
)
|
54 |
st.write("#")
|
55 |
|
56 |
-
|
57 |
-
show_search_results()
|
58 |
|
59 |
def set_page_config(self):
|
60 |
st.set_page_config(
|
@@ -63,5 +34,30 @@ class SearchApplication:
|
|
63 |
layout="centered",
|
64 |
)
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
if __name__ == "__main__":
|
67 |
SearchApplication()
|
|
|
10 |
st.error("Failed to fetch README.md content from GitHub.")
|
11 |
return ""
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
class SearchApplication:
|
14 |
def __init__(self):
|
15 |
self.title = "Awesome Awesome Artificial Intelligence Search"
|
|
|
18 |
st.header(self.title)
|
19 |
col1, col2 = st.columns(2)
|
20 |
with col1:
|
21 |
+
self.query = st.text_input("Search", value="", on_change=self.rerun)
|
|
|
|
|
|
|
|
|
22 |
|
23 |
st.caption(
|
24 |
"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."
|
25 |
)
|
26 |
st.write("#")
|
27 |
|
28 |
+
self.show_search_results()
|
|
|
29 |
|
30 |
def set_page_config(self):
|
31 |
st.set_page_config(
|
|
|
34 |
layout="centered",
|
35 |
)
|
36 |
|
37 |
+
def rerun(self):
|
38 |
+
st.experimental_rerun()
|
39 |
+
|
40 |
+
def show_search_results(self):
|
41 |
+
if self.query:
|
42 |
+
st.write("#")
|
43 |
+
|
44 |
+
readme_content = fetch_readme_content()
|
45 |
+
|
46 |
+
if readme_content:
|
47 |
+
search_results = []
|
48 |
+
lines = readme_content.split("\n")
|
49 |
+
for line in lines:
|
50 |
+
if self.query.lower() in line.lower():
|
51 |
+
search_results.append(line)
|
52 |
+
|
53 |
+
num_search_results = len(search_results)
|
54 |
+
st.write(f"A total of {num_search_results} matches found.")
|
55 |
+
|
56 |
+
if num_search_results > 0:
|
57 |
+
for result in search_results:
|
58 |
+
st.write(result)
|
59 |
+
else:
|
60 |
+
st.write("No matches found.")
|
61 |
+
|
62 |
if __name__ == "__main__":
|
63 |
SearchApplication()
|