joshuadunlop commited on
Commit
01c1e26
·
verified ·
1 Parent(s): 2c02e47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -62,7 +62,7 @@ api_login = st.sidebar.text_input("API Login", value="[email protected]
62
  api_key = st.sidebar.text_input("API Key", type="password")
63
 
64
  st.sidebar.title("Filters")
65
- st.sidebar.info ("A maximum of 8 filters are allowed through the API. That includes one for every comma-separated value below, one for every value not equal to 0 in the boxes, one for language, and one for each button ticked.")
66
  url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)", value="keyword,blogspot,/search,/tag")
67
  backlink_spam_score = st.sidebar.number_input("Backlink Spam Score ≤", value=20)
68
  page_from_rank_value = st.sidebar.number_input("Page From Rank Value ≥", value=0)
@@ -132,7 +132,7 @@ if reset:
132
 
133
  row_count = st.session_state.get("row_count", 1)
134
 
135
- generate_button = st.sidebar.button("Generate All") # Define generate_button before its first use
136
 
137
  if generate_button:
138
  jobs = Queue()
@@ -171,5 +171,20 @@ for i in range(row_count):
171
  file_name=f'backlinks_{i + 1}.csv',
172
  mime='text/csv',
173
  )
174
- elif df is None and generate_button:
175
- cols[1].error(f"Failed to generate CSV for URL {i + 1}: No data returned from the API or data processing error.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  api_key = st.sidebar.text_input("API Key", type="password")
63
 
64
  st.sidebar.title("Filters")
65
+ st.sidebar.info("A maximum of 8 filters are allowed through the API. That includes one for every comma-separated value below, one for every value not equal to 0 in the boxes, one for language, and one for each button ticked.")
66
  url_from_not_contain = st.sidebar.text_input("URL from does not contain (comma-separated)", value="keyword,blogspot,/search,/tag")
67
  backlink_spam_score = st.sidebar.number_input("Backlink Spam Score ≤", value=20)
68
  page_from_rank_value = st.sidebar.number_input("Page From Rank Value ≥", value=0)
 
132
 
133
  row_count = st.session_state.get("row_count", 1)
134
 
135
+ generate_button = st.sidebar.button("Generate All")
136
 
137
  if generate_button:
138
  jobs = Queue()
 
171
  file_name=f'backlinks_{i + 1}.csv',
172
  mime='text/csv',
173
  )
174
+
175
+ # Function to concatenate all DataFrames and convert to CSV for download
176
+ def concatenate_dfs_and_download():
177
+ dfs = [st.session_state[key] for key in st.session_state.keys() if key.startswith('df_') and st.session_state[key] is not None]
178
+ if dfs:
179
+ combined_df = pd.concat(dfs, ignore_index=True)
180
+ csv = combined_df.to_csv(index=False).encode('utf-8')
181
+ st.sidebar.download_button(
182
+ label="Download All as CSV",
183
+ data=csv,
184
+ file_name='all_backlinks.csv',
185
+ mime='text/csv',
186
+ )
187
+ else:
188
+ st.sidebar.write("No data available to download.")
189
+
190
+ concatenate_dfs_and_download()