joshuadunlop commited on
Commit
a625ffd
·
verified ·
1 Parent(s): 1c7f3d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import pandas as pd
3
  import requests
4
  import base64
5
- import io
6
 
7
  def get_backlinks(api_login, api_key, target_url, filters):
8
  # Encoding credentials
@@ -97,15 +96,15 @@ reset_button = st.sidebar.button("Reset")
97
  if generate_button and target_url:
98
  df = get_backlinks(api_login, api_key, target_url, filters)
99
  if df is not None:
100
- # Display the DataFrame in the second column
 
 
 
 
101
  with col2:
102
  st.header("Output")
103
- st.dataframe(df)
104
-
105
- # Convert DataFrame to CSV
106
- csv = df.to_csv(index=False).encode('utf-8')
107
- b64 = base64.b64encode(csv).decode() # Convert bytes to base64 encoded string
108
- download_link = st.download_button(label="Download data as CSV", data=b64, file_name='backlinks_data.csv', mime='text/csv')
109
 
110
  # Reset functionality
111
  if reset_button:
 
2
  import pandas as pd
3
  import requests
4
  import base64
 
5
 
6
  def get_backlinks(api_login, api_key, target_url, filters):
7
  # Encoding credentials
 
96
  if generate_button and target_url:
97
  df = get_backlinks(api_login, api_key, target_url, filters)
98
  if df is not None:
99
+ # Convert DataFrame to CSV
100
+ csv = df.to_csv(index=False)
101
+ # Convert CSV to a string
102
+ b64 = base64.b64encode(csv.encode()).decode()
103
+ href = f'<a href="data:file/csv;base64,{b64}" download="backlinks.csv">Download CSV file</a>'
104
  with col2:
105
  st.header("Output")
106
+ # Display the download link
107
+ st.markdown(href, unsafe_allow_html=True)
 
 
 
 
108
 
109
  # Reset functionality
110
  if reset_button: