awacke1 commited on
Commit
ce272a5
·
verified ·
1 Parent(s): 2e679f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -34
app.py CHANGED
@@ -14,6 +14,8 @@ if 'view_mode' not in st.session_state:
14
  st.session_state.view_mode = 'view'
15
  if 'files' not in st.session_state:
16
  st.session_state.files = []
 
 
17
 
18
  # Define the markdown variables
19
  Boxing_and_MMA_Commentary_and_Knowledge = """
@@ -32,17 +34,16 @@ Boxing_and_MMA_Commentary_and_Knowledge = """
32
  - BJ Penn
33
  - Anderson Silva
34
  - Mighty Mouse MMA's heart at 125 pounds
35
- - Kabib retired 29 and 0
36
- - Fedor Milliano
37
  - Alex Pereira
38
- - James Tony
39
  - Randy Couture
40
  3. You have to Judge them in their Championship Peak
41
  4. Chris Weidman
42
- 5. Connor McGregor
43
  6. Leg Breaking - Shin calcification and breaking baseball bats
44
 
45
-
46
  # References:
47
  1. Joe Rogan - Interview #2219
48
  2. Donald J Trump
@@ -51,33 +52,33 @@ Boxing_and_MMA_Commentary_and_Knowledge = """
51
  Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
52
  # Multiplayer Simulated Worlds
53
 
54
- 1. 7 Days To Die PC
55
- 2. ARK: Survival Evolved PC
56
- 3. Arma 3 PC
57
- 4. Atlas PC
58
- 5. Conan Exiles PC
59
- 6. Craftopia PC
60
- 7. DayZ PC
61
- 8. Eco - Global Survival PC
62
- 9. Empyrion - Galactic Survival PC
63
- 10. Factorio PC
64
- 11. Farming Simulator 19 PC
65
  12. Crossplay
66
- 13. Farming Simulator 22
67
- 14. Last Oasis PC
68
- 15. Last Oasis Classic PC
69
- 16. Minecraft (Vanilla) PC
70
  17. Crossplay
71
  18. Path of Titans
72
- 19. Rust PC
73
- 20. SCP: Secret Laboratory PC
74
  21. SCUM PC
75
  22. Satisfactory PC
76
- 23. Satisfactory (Experimental) PC
77
  24. Crossplay
78
- 25. Space Engineers
79
- 26. Terraria (tShock & Vanilla) PC
80
- 27. The Forest PC
81
  28. Crossplay
82
  29. Valheim
83
  """
@@ -96,7 +97,7 @@ def extract_terms(markdown_text):
96
  def display_terms_with_links(terms):
97
  def generate_arxiv_link(term):
98
  params = {'term': term}
99
- url = f"/?{urlencode(params)}"
100
  return url
101
 
102
  search_urls = {
@@ -177,10 +178,10 @@ def generate_filename(prefix, content, ai_output):
177
 
178
  # Function to process query parameters and handle AI lookup
179
  def process_query_parameters():
180
- query_params = st.query_params
181
- term = query_params.get('term', None)
182
- if term:
183
- term = term[0] # Get the first value
184
  if len(term) > 1:
185
  st.write(f"### Search term received: {term}")
186
  # Perform AI lookup
@@ -195,10 +196,12 @@ def process_query_parameters():
195
  f.write(markdown_text)
196
  st.write(f"Generated file **{filename}** with AI lookup results.")
197
  # Clear the query parameters
198
- st.set_query_params()
199
  # Update session state
200
  st.session_state.selected_file = filename
201
  st.session_state.view_mode = 'view'
 
 
202
 
203
  # Sidebar for file management
204
  def file_management_sidebar():
@@ -235,6 +238,7 @@ def file_management_sidebar():
235
  st.sidebar.success(f"Created new file: {new_filename}")
236
  st.session_state.selected_file = new_filename
237
  st.session_state.view_mode = 'edit'
 
238
  else:
239
  st.sidebar.write("No markdown files found.")
240
  if st.sidebar.button("Create New Markdown File"):
@@ -246,6 +250,7 @@ def file_management_sidebar():
246
  st.sidebar.success(f"Created new file: {new_filename}")
247
  st.session_state.selected_file = new_filename
248
  st.session_state.view_mode = 'edit'
 
249
 
250
  # Main application logic
251
  def main():
@@ -267,7 +272,7 @@ def main():
267
  display_terms_with_links(all_terms)
268
 
269
  # Handle 'action' and 'query' parameters (if needed)
270
- params = st.query_params
271
  if 'action' in params:
272
  action_list = params['action']
273
  if action_list:
@@ -276,7 +281,7 @@ def main():
276
  st.success("Showing a message because 'action=show_message' was found in the URL.")
277
  elif action == 'clear':
278
  # Clear query parameters
279
- st.set_query_params()
280
  if 'query' in params:
281
  query_list = params['query']
282
  if query_list:
@@ -288,6 +293,11 @@ def main():
288
  # File management sidebar
289
  file_management_sidebar()
290
 
 
 
 
 
 
291
  # Display the selected file
292
  selected_file = st.session_state.get('selected_file')
293
  if selected_file:
 
14
  st.session_state.view_mode = 'view'
15
  if 'files' not in st.session_state:
16
  st.session_state.files = []
17
+ if 'file_list_updated' not in st.session_state:
18
+ st.session_state.file_list_updated = False
19
 
20
  # Define the markdown variables
21
  Boxing_and_MMA_Commentary_and_Knowledge = """
 
34
  - BJ Penn
35
  - Anderson Silva
36
  - Mighty Mouse MMA's heart at 125 pounds
37
+ - Khabib retired 29 and 0
38
+ - Fedor Emelianenko
39
  - Alex Pereira
40
+ - James Toney
41
  - Randy Couture
42
  3. You have to Judge them in their Championship Peak
43
  4. Chris Weidman
44
+ 5. Conor McGregor
45
  6. Leg Breaking - Shin calcification and breaking baseball bats
46
 
 
47
  # References:
48
  1. Joe Rogan - Interview #2219
49
  2. Donald J Trump
 
52
  Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
53
  # Multiplayer Simulated Worlds
54
 
55
+ 1. 7 Days To Die PC
56
+ 2. ARK: Survival Evolved PC
57
+ 3. Arma 3 PC
58
+ 4. Atlas PC
59
+ 5. Conan Exiles PC
60
+ 6. Craftopia PC
61
+ 7. DayZ PC
62
+ 8. Eco - Global Survival PC
63
+ 9. Empyrion - Galactic Survival PC
64
+ 10. Factorio PC
65
+ 11. Farming Simulator 19 PC
66
  12. Crossplay
67
+ 13. Farming Simulator 22
68
+ 14. Last Oasis PC
69
+ 15. Last Oasis Classic PC
70
+ 16. Minecraft (Vanilla) PC
71
  17. Crossplay
72
  18. Path of Titans
73
+ 19. Rust PC
74
+ 20. SCP: Secret Laboratory PC
75
  21. SCUM PC
76
  22. Satisfactory PC
77
+ 23. Satisfactory (Experimental) PC
78
  24. Crossplay
79
+ 25. Space Engineers
80
+ 26. Terraria (tShock & Vanilla) PC
81
+ 27. The Forest PC
82
  28. Crossplay
83
  29. Valheim
84
  """
 
97
  def display_terms_with_links(terms):
98
  def generate_arxiv_link(term):
99
  params = {'term': term}
100
+ url = f"{st.experimental_get_url()}?{urlencode(params)}"
101
  return url
102
 
103
  search_urls = {
 
178
 
179
  # Function to process query parameters and handle AI lookup
180
  def process_query_parameters():
181
+ query_params = st.experimental_get_query_params()
182
+ term_list = query_params.get('term', None)
183
+ if term_list:
184
+ term = term_list[0] # Get the first value
185
  if len(term) > 1:
186
  st.write(f"### Search term received: {term}")
187
  # Perform AI lookup
 
196
  f.write(markdown_text)
197
  st.write(f"Generated file **{filename}** with AI lookup results.")
198
  # Clear the query parameters
199
+ st.experimental_set_query_params()
200
  # Update session state
201
  st.session_state.selected_file = filename
202
  st.session_state.view_mode = 'view'
203
+ # Mark that the file list needs to be updated
204
+ st.session_state.file_list_updated = True
205
 
206
  # Sidebar for file management
207
  def file_management_sidebar():
 
238
  st.sidebar.success(f"Created new file: {new_filename}")
239
  st.session_state.selected_file = new_filename
240
  st.session_state.view_mode = 'edit'
241
+ st.session_state.file_list_updated = True
242
  else:
243
  st.sidebar.write("No markdown files found.")
244
  if st.sidebar.button("Create New Markdown File"):
 
250
  st.sidebar.success(f"Created new file: {new_filename}")
251
  st.session_state.selected_file = new_filename
252
  st.session_state.view_mode = 'edit'
253
+ st.session_state.file_list_updated = True
254
 
255
  # Main application logic
256
  def main():
 
272
  display_terms_with_links(all_terms)
273
 
274
  # Handle 'action' and 'query' parameters (if needed)
275
+ params = st.experimental_get_query_params()
276
  if 'action' in params:
277
  action_list = params['action']
278
  if action_list:
 
281
  st.success("Showing a message because 'action=show_message' was found in the URL.")
282
  elif action == 'clear':
283
  # Clear query parameters
284
+ st.experimental_set_query_params()
285
  if 'query' in params:
286
  query_list = params['query']
287
  if query_list:
 
293
  # File management sidebar
294
  file_management_sidebar()
295
 
296
+ # Update file list if needed
297
+ if st.session_state.get('file_list_updated', False):
298
+ st.session_state.files = [file for file in glob.glob("*.md") if os.path.basename(file).lower() != 'readme.md']
299
+ st.session_state.file_list_updated = False
300
+
301
  # Display the selected file
302
  selected_file = st.session_state.get('selected_file')
303
  if selected_file: