Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -213,12 +213,6 @@ def file_management_sidebar():
|
|
213 |
st.session_state.selected_file = new_filename
|
214 |
st.session_state.view_mode = 'edit'
|
215 |
|
216 |
-
def get_all_query_params(key):
|
217 |
-
return st.query_params().get(key, [])
|
218 |
-
|
219 |
-
def clear_query_params():
|
220 |
-
st.query_params()
|
221 |
-
|
222 |
|
223 |
# Main application logic
|
224 |
def main():
|
@@ -239,28 +233,20 @@ def main():
|
|
239 |
# Process 'q' query parameter from the URL
|
240 |
try:
|
241 |
query_params = st.query_params
|
242 |
-
|
243 |
-
if
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
with open(filename, 'w', encoding='utf-8') as f:
|
257 |
-
f.write(markdown_text)
|
258 |
-
st.write(f"Generated file **{filename}** with AI lookup results.")
|
259 |
-
|
260 |
-
|
261 |
-
st.query_params.clear()
|
262 |
-
st.session_state.selected_file = filename
|
263 |
-
st.session_state.view_mode = 'view'
|
264 |
|
265 |
except Exception as e:
|
266 |
st.write(f"An error occurred while processing query parameters: {e}")
|
@@ -268,20 +254,19 @@ def main():
|
|
268 |
# Handle 'action' and 'query' parameters
|
269 |
params = st.query_params
|
270 |
if 'action' in params:
|
271 |
-
|
272 |
-
if
|
273 |
-
action
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
# Clear query parameters
|
278 |
-
st.query_params.clear()
|
279 |
|
280 |
-
if 'query' in
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
285 |
|
286 |
# File management sidebar
|
287 |
file_management_sidebar()
|
|
|
213 |
st.session_state.selected_file = new_filename
|
214 |
st.session_state.view_mode = 'edit'
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
# Main application logic
|
218 |
def main():
|
|
|
233 |
# Process 'q' query parameter from the URL
|
234 |
try:
|
235 |
query_params = st.query_params
|
236 |
+
query = (query_params.get('q') or query_params.get('query') or [''])
|
237 |
+
if len(query) > 1:
|
238 |
+
st.write(f"### Search query received: {query}")
|
239 |
+
ai_result = perform_ai_lookup(query)
|
240 |
+
markdown_text = extract_urls(ai_result)
|
241 |
+
st.markdown("## Extracted URLs")
|
242 |
+
st.markdown(markdown_text)
|
243 |
+
filename = generate_filename(ai_result, query)
|
244 |
+
with open(filename, 'w', encoding='utf-8') as f:
|
245 |
+
f.write(markdown_text)
|
246 |
+
st.write(f"Generated file **{filename}** with AI results for {query}")
|
247 |
+
st.query_params.clear()
|
248 |
+
st.session_state.selected_file = filename
|
249 |
+
st.session_state.view_mode = 'view'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
except Exception as e:
|
252 |
st.write(f"An error occurred while processing query parameters: {e}")
|
|
|
254 |
# Handle 'action' and 'query' parameters
|
255 |
params = st.query_params
|
256 |
if 'action' in params:
|
257 |
+
action = st.query_params()['action'][0]
|
258 |
+
if action == 'show_message':
|
259 |
+
st.success("Showing a message because 'action=show_message' was found in the URL.")
|
260 |
+
elif action == 'clear':
|
261 |
+
# Clear query parameters
|
262 |
+
st.query_params.clear()
|
|
|
|
|
263 |
|
264 |
+
if 'query' in st.query_params:
|
265 |
+
query = st.query_params['query'][0] # Get the query parameter
|
266 |
+
# Display content or image based on the query
|
267 |
+
#display_content_or_image(query)
|
268 |
+
st.markdown("To Implement:")
|
269 |
+
st.markdown(query)
|
270 |
|
271 |
# File management sidebar
|
272 |
file_management_sidebar()
|