Spaces:
Sleeping
Sleeping
grapplerulrich
commited on
Commit
·
0e7333a
1
Parent(s):
59d5e33
Add debug mode & improve layout
Browse files
app.py
CHANGED
@@ -69,8 +69,10 @@ def content_summary( url_id, content ):
|
|
69 |
return summary
|
70 |
|
71 |
def main():
|
72 |
-
st.title('
|
73 |
query = st.text_input('Search query')
|
|
|
|
|
74 |
if query :
|
75 |
with st.spinner('Loading search results...'):
|
76 |
try:
|
@@ -80,25 +82,21 @@ def main():
|
|
80 |
return
|
81 |
|
82 |
number_of_results = len( results )
|
83 |
-
st.success( 'Found {} results.'.format( number_of_results ) )
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
progress_bar = st.progress(0)
|
|
|
90 |
|
91 |
# for result in results:
|
92 |
for index, result in enumerate(results):
|
93 |
with st.container():
|
94 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
95 |
-
st.write(result['link'])
|
96 |
-
st.write(url_id)
|
97 |
-
# if st.button('URL HTML'):
|
98 |
-
# st.json( results )
|
99 |
-
|
100 |
-
# if st.button('Page content'):
|
101 |
-
# st.json( results )
|
102 |
|
103 |
try:
|
104 |
content = get_url_content( result['link'] )
|
@@ -114,14 +112,19 @@ def main():
|
|
114 |
|
115 |
progress_bar.progress( ( index + 1 ) / number_of_results )
|
116 |
|
117 |
-
col1, col2 = st.columns(
|
118 |
with col1:
|
119 |
-
|
120 |
-
remove( 'summaries/' + url_id + '.json' )
|
121 |
|
122 |
with col2:
|
123 |
if st.button('Delete content cache', key=url_id + 'content'):
|
124 |
remove( 'page-content/' + url_id + '.txt' )
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
|
127 |
if __name__ == '__main__':
|
|
|
69 |
return summary
|
70 |
|
71 |
def main():
|
72 |
+
st.title('Racoon Search')
|
73 |
query = st.text_input('Search query')
|
74 |
+
query_params = st.experimental_get_query_params()
|
75 |
+
|
76 |
if query :
|
77 |
with st.spinner('Loading search results...'):
|
78 |
try:
|
|
|
82 |
return
|
83 |
|
84 |
number_of_results = len( results )
|
85 |
+
st.success( 'Found {} results for "{}".'.format( number_of_results, query ) )
|
86 |
|
87 |
+
if 'debug' in query_params.keys() and query_params['debug'][0] == 'true':
|
88 |
+
with st.expander("Search results JSON"):
|
89 |
+
if st.button('Delete search result cache', key=query + 'cache'):
|
90 |
+
remove( 'search-results/' + slugify( query ) + '.json' )
|
91 |
+
st.json( results )
|
92 |
|
93 |
progress_bar = st.progress(0)
|
94 |
+
st.markdown('---')
|
95 |
|
96 |
# for result in results:
|
97 |
for index, result in enumerate(results):
|
98 |
with st.container():
|
99 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
try:
|
102 |
content = get_url_content( result['link'] )
|
|
|
112 |
|
113 |
progress_bar.progress( ( index + 1 ) / number_of_results )
|
114 |
|
115 |
+
col1, col2, col3 = st.columns(3)
|
116 |
with col1:
|
117 |
+
st.markdown('[Website Link]({})'.format(result['link']))
|
|
|
118 |
|
119 |
with col2:
|
120 |
if st.button('Delete content cache', key=url_id + 'content'):
|
121 |
remove( 'page-content/' + url_id + '.txt' )
|
122 |
+
|
123 |
+
with col3:
|
124 |
+
if st.button('Delete summary cache', key=url_id + 'summary'):
|
125 |
+
remove( 'summaries/' + url_id + '.json' )
|
126 |
+
|
127 |
+
st.markdown('---')
|
128 |
|
129 |
|
130 |
if __name__ == '__main__':
|