awacke1 commited on
Commit
32a3806
·
verified ·
1 Parent(s): 2f38a4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -41
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
- query_list = query_params.get('q') or query_params.get('query') or []
243
- if query_list:
244
- search_query = query_list[0]
245
- if len(search_query) > 1:
246
-
247
-
248
- st.write(f"### Search query received: {search_query}")
249
- ai_result = perform_ai_lookup(search_query)
250
- markdown_text = extract_urls(ai_result)
251
- st.markdown("## Extracted URLs")
252
- st.markdown(markdown_text)
253
-
254
-
255
- filename = generate_filename("AI_Result", search_query)
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
- action_list = params['action']
272
- if action_list:
273
- action = action_list[0]
274
- if action == 'show_message':
275
- st.success("Showing a message because 'action=show_message' was found in the URL.")
276
- elif action == 'clear':
277
- # Clear query parameters
278
- st.query_params.clear()
279
 
280
- if 'query' in params:
281
- query_list = params['query']
282
- if query_list:
283
- query = query_list[0]
284
- st.write(f"Displaying content for query: {query}")
 
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()