shashnk commited on
Commit
58a57f4
·
1 Parent(s): 4a2a303

Update influencer_onboarding.py

Browse files
Files changed (1) hide show
  1. influencer_onboarding.py +60 -33
influencer_onboarding.py CHANGED
@@ -1,26 +1,27 @@
1
  import streamlit as st
2
  import requests
3
 
4
- influencers_data = {
5
- "influencer1": {
6
- "onboarded": True,
7
- "name": "Influencer One",
8
- "image": "./images/inf1.png", # Replace with actual image paths
9
- "details": "Details about Influencer One..."
10
- },
11
- "influencer2": {
12
- "onboarded": True,
13
- "name": "Influencer Two",
14
- "image": "./images/inf2.png",
15
- "details": "Details about Influencer Two..."
16
- },
17
- "influencer3": {
18
- "onboarded": False,
19
- "name": "Influencer Two",
20
- "image": "./images/inf2.png"
21
- }
22
- # Add more influencers as needed
23
- }
 
24
 
25
  def onboard_single_influencer(handle):
26
  url = "https://us-central1-steam-cache-277314.cloudfunctions.net/create_insta_task"
@@ -60,18 +61,44 @@ def onboard_influencers_from_file(file):
60
 
61
  def display_onboarded_influencers():
62
  # Display the list of onboarded influencers
63
- st.write("List of Onboarded Influencers...")
64
- for influencer_id, influencer_info in influencers_data.items():
65
- col1, col2 = st.columns([1, 3])
 
 
 
66
 
67
- with col1:
68
- st.image(influencer_info["image"], width=30)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
- with col2:
71
- if(influencer_info["onboarded"]):
72
- with st.expander("Influencer Details"):
73
- st.subheader(influencer_info["name"])
74
- st.write(influencer_info["details"])
75
- else:
76
- with st.expander("Influencer Onboarding - In Progress"):
77
- st.write("Onboarding - In Progress")
 
1
  import streamlit as st
2
  import requests
3
 
4
+ # influencers_data = {
5
+ # "influencer1": {
6
+ # "onboarded": True,
7
+ # "name": "Influencer One",
8
+ # "image": "./images/inf1.png", # Replace with actual image paths
9
+ # "details": "Details about Influencer One..."
10
+ # },
11
+ # "influencer2": {
12
+ # "onboarded": True,
13
+ # "name": "Influencer Two",
14
+ # "image": "./images/inf2.png",
15
+ # "details": "Details about Influencer Two..."
16
+ # },
17
+ # "influencer3": {
18
+ # "onboarded": False,
19
+ # "name": "Influencer Two",
20
+ # "image": "./images/inf2.png"
21
+ # }
22
+ # # Add more influencers as needed
23
+ # }
24
+
25
 
26
  def onboard_single_influencer(handle):
27
  url = "https://us-central1-steam-cache-277314.cloudfunctions.net/create_insta_task"
 
61
 
62
  def display_onboarded_influencers():
63
  # Display the list of onboarded influencers
64
+
65
+ get_all_url = "https://us-central1-steam-cache-277314.cloudfunctions.net/get_all_influencer"
66
+ data = {"handle": handle}
67
+ response = requests.post(get_all_url, json=data)
68
+ if response.status_code == 200:
69
+ st.write("List of Onboarded Influencers...")
70
 
71
+ influencers_list = json.loads(response.text)
72
+ for influencer_data in influencers_list:
73
+ # Download image
74
+ profile_img_url = influencer_data.get('profile_image_url', profile_default_image_url)
75
+ img_response = requests.get(profile_img_url)
76
+ image_url = profile_default_image_url
77
+ if img_response.status_code == 200:
78
+ image_url = f"downloaded_image_{influencer_data.get('handle', 'NoName')}.jpg"
79
+ with open(image_url, "wb") as file:
80
+ file.write(img_response.content)
81
+
82
+ # Display influencer data
83
+ col1, col2 = st.columns([1, 3])
84
+ with col1:
85
+ st.image(image_url, width=150)
86
+
87
+ with col2:
88
+ with st.expander(f"{influencer_data.get('name', 'No Name')}'s Details"):
89
+ st.markdown(f"**Handle:** {influencer_data.get('handle', 'No Handle')}")
90
+ st.markdown(f"**Bio:** {influencer_data.get('bio', 'No Bio')}")
91
+ st.markdown(f"**Email:** {influencer_data.get('email', 'N/A')}")
92
+ st.markdown(f"**Country:** {influencer_data.get('country', 'N/A')}")
93
+ st.markdown(f"**Location:** {influencer_data.get('location', 'N/A')}")
94
+ st.markdown(f"**Followers Count:** {influencer_data.get('followers_count', 'N/A')}")
95
+ st.markdown(f"**Engagement Rate:** {influencer_data.get('engagement_rate', 'N/A')*100:.2f}%")
96
+ st.markdown("### Frequent Hashtags")
97
+ hashtags = influencer_data.get('frequent_hashtags', [])
98
+ st.write(", ".join(hashtags))
99
+ st.markdown("### Post Summary")
100
+ st.write(influencer_data.get('post_summary', 'N/A'))
101
+
102
+ else:
103
+ st.write(response["data"]["error"])
104