File size: 12,567 Bytes
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28fda2a
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
664162f
7371c94
 
664162f
 
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
069e72b
7aee407
069e72b
7371c94
 
 
069e72b
7371c94
664162f
 
069e72b
 
 
7371c94
 
 
 
 
069e72b
7371c94
 
 
 
28fda2a
7371c94
 
 
 
 
 
 
 
 
069e72b
7371c94
 
 
 
 
 
664162f
7371c94
 
 
 
 
 
 
069e72b
f5ac5a7
 
7371c94
 
069e72b
7371c94
 
7aee407
 
 
 
 
 
 
 
 
 
 
 
 
 
7371c94
 
 
4bf6bcd
7371c94
3a19db4
 
 
4bf6bcd
3a19db4
 
 
 
0b66107
 
a05281c
 
ec9afe8
a05281c
 
4bf6bcd
7371c94
 
 
 
 
7aee407
 
2696d63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7aee407
 
 
 
 
 
 
 
 
 
7371c94
2696d63
7371c94
 
 
 
7aee407
069e72b
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b66107
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7aee407
7371c94
 
 
 
 
 
 
 
 
 
 
 
 
 
7aee407
7371c94
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# front_end.py

import gradio as gr
import requests
import pandas as pd
import plotly.express as px
import os

# Configuration
BACKEND_URL = os.environ.get("SERVER_URL")

def validate_email(email):
    """Basic email validation"""
    return '@' in email and '.' in email.split('@')[1]

def generate_affiliate(email, secret):
    """Generate affiliate ID and private key"""
    if not email or not secret:
        return "Please provide both email and secret", "", ""
    
    if not validate_email(email):
        return "Please provide a valid email address", "", ""
    
    if len(secret) < 6:
        return "Secret must be at least 6 characters long", "", ""
    
    try:
        response = requests.post(
            f"{BACKEND_URL}/generate-affiliate",
            json={"email": email, "secret": secret}
        )
        
        if response.status_code == 200:
            data = response.json()
            return (
                "Affiliate ID generated successfully! Please save your private key securely.",
                data['affiliate_id'],
                data['private_key']
            )
        else:
            error_msg = response.json().get('message', 'Unknown error occurred')
            return f"Error: {error_msg}", "", ""
            
    except Exception as e:
        return "Error: Unable to connect to server", "", ""

def create_commission_chart(df):
    result = df.groupby("date")["amount"].sum().reset_index()
    """Create commission history chart"""
    fig = px.bar(
        result,
        x='date',
        y='amount',
        title='Daily Commission History'
    )
    fig.update_layout(
        xaxis_title="Date",
        yaxis_title="Daily Commission Amount ($)",
        hovermode='x unified',
        showlegend=False,
        plot_bgcolor='white',
        paper_bgcolor='white',
        bargap=0.2
    )
    fig.update_traces(
        marker_color='#2E86C1',
        hovertemplate="Date: %{x}<br>Commission: $%{y:.2f}<extra></extra>"
    )
    fig.update_xaxes(
        gridcolor='lightgray',
        showgrid=True
    )
    fig.update_yaxes(
        gridcolor='lightgray',
        showgrid=True
    )
    return fig

COLUMN_LIST = ['Datetime', 'Order ID', 'Order Amount ($)', 'Commission ($)']
COLUMN_LB = ['Affiliate ID', 'Duration (Days)', 'Sales', 'Commission ($)']

def format_commission_data(df):
    """Format commission data for display"""
    if df is None or df.empty:
        return pd.DataFrame(columns=COLUMN_LIST)
    
    df['time'] = df['timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S')
    df['date'] = df['timestamp'].dt.strftime('%Y-%m-%d')
    df['commission_amount'] = (df['amount'] / 5).round(2)
    display_df = df[['time', 'order_id', 'amount', 'commission_amount']].copy()
    display_df.columns = COLUMN_LIST
    return display_df

def show_commission_history(private_key):
    """Fetch and display commission history"""
    if not private_key:
        empty_df = pd.DataFrame(columns=COLUMN_LIST)
        return "Please provide your private key", None, empty_df
    
    try:
        response = requests.post(
            f"{BACKEND_URL}/commission-history",
            json={"private_key": private_key}
        )
        
        if response.status_code == 200:
            data = response.json()
            commission_history = data['commission_history']
            total_commission = data['total_commission']
            
            if not commission_history:
                empty_df = pd.DataFrame(columns=COLUMN_LIST)
                return "No commission history found", None, empty_df
            
            df = pd.DataFrame(commission_history)
            df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
            
            display_df = format_commission_data(df)
            chart = create_commission_chart(df)
            
            return (
                f"Total Commission: ${total_commission:,.2f}",
                chart,
                display_df
            )
        else:
            error_msg = 'Private Key invalid'
            empty_df = pd.DataFrame(columns=COLUMN_LIST)
            return f"Error: {error_msg}", None, empty_df
            
    except Exception as e:
        empty_df = pd.DataFrame(columns=COLUMN_LIST)
        return "Error: Unable to connect to server", None, empty_df

def on_page_load():
    try:
        response = requests.post(f"{BACKEND_URL}/affiliate-leaderboard")
        if response.status_code == 200:
            data = response.json()
            leaderboard_df = pd.DataFrame(data['leaderboard'])
            leaderboard_df.columns = COLUMN_LB
            return leaderboard_df
        else:
            return pd.DataFrame(columns=COLUMN_LB)
    except Exception as e:
        return pd.DataFrame(columns=COLUMN_LB)


# Create Gradio interface
with gr.Blocks(title="FaceOnLive Face Search Affiliate Program") as app:
    gr.Markdown("""
    # FaceOnLive Face Search API & Affiliate Program (50%)
    
    ## Ranked Top 3 on Google for "Face Search"!  
    Here's why you'll love it:

    **βœ… High Commission & Conversion Rate**: Earn 50% commision, converting over 8% β€” higher than most programs!  
    **βœ… Flexible Methods**: Share affiliate links or embed our high-traffic Face Search widget.  
    **βœ… Inclusive & Easy**: Open to everyone, no tech skills required.  
    **βœ… Instant Payouts**: No minimum threshold + flexible payout options. (bank transfer, payoneer, wise, paypal, crypto)  
    **βœ… Dedicated Support**: 24/7 support for all affiliates.  
    
    ### Check our service on our website: [Face Search Online](https://faceonlive.com/face-search-online)
    
    ## 1. API Integration
    ### We charge $0.1 per call for FREEMIUM API and $2.5 per call for PREMIUM API (Deep Search with Social Media).  
    ### For API integration inquiries, please reach out to us using the contact details at the bottom of this page.  

    ## 2. Affiliate Program (50%)
    ### Check guide below for more details on how to start and earn commissions.  
    """)
    
    with gr.Tabs():
        with gr.TabItem("Commission History"):
            with gr.Row():                
                with gr.Column(scale=6):
                    gr.Markdown("### View Your Commission History (Private Key Required)")
                    private_key_input = gr.Textbox(
                        label="Private Key",
                        placeholder="Enter your private key",
                        type="password"
                    )
                    
                    show_history_btn = gr.Button(
                        "Show Commission History",
                        variant="primary"
                    )
                    
                    total_commission_output = gr.Textbox(
                        label="Total Commission",
                        interactive=False
                    )
                with gr.Column(scale=1):
                    gr.HTML("<div'></div>")
                with gr.Column(scale=5):
                    with gr.Group():
                        gr.Markdown("### Affiliate Sales Leaderboard")
                        aff_leaderboard_table = gr.DataFrame(
                            headers=COLUMN_LB,
                            interactive=False,
                            wrap=True
                        )
            
            with gr.Row():                
                commission_chart = gr.Plot(
                    label="Commission History Chart"
                )
                commission_table = gr.DataFrame(
                    label="Your Commission History",
                    headers=COLUMN_LIST,
                    interactive=False,
                    wrap=True
                )
                
        with gr.TabItem("Generate Affiliate ID"):
            gr.Markdown("### Create New Affiliate Account")
            
            with gr.Row():
                email_input = gr.Textbox(
                    label="Email",
                    placeholder="Enter your email address"
                )
                secret_input = gr.Textbox(
                    label="Secret",
                    placeholder="Enter a secret phrase (min 6 characters)",
                    type="password"
                )
            
            generate_btn = gr.Button(
                "Generate Affiliate ID",
                variant="primary"
            )
            
            status_output = gr.Textbox(
                label="Status",
                interactive=False
            )
            
            with gr.Row():
                affiliate_id_output = gr.Textbox(
                    label="Affiliate ID",
                    interactive=False,
                    show_copy_button=True
                )
                private_key_output = gr.Textbox(
                    label="Private Key",
                    interactive=False,
                    show_copy_button=True
                )
            
            gr.Markdown("""
            > **Important Notes**: 
            > * Save your private key securely! You'll need it to access your commission history.
            > * The private key cannot be recovered if lost.
            > * Never share your private key with anyone.
            """)
    
    gr.Markdown("""

---

## How to Start?

Generate affiliate_id by providing your email and secret in the panel above under the "Generate Affiliate ID" tab.
(On mobile devices, tab may be displayed as "...", tap on it.)

You can participate in our affiliate program in two simple ways: easily share your unique link or embed our face search widget on your website.
### 1. Easy Sharing
Share our website using your `affiliate_id` in the URL. Affiliate IDs are automatically applied to all checkout links.  

Example:  
`https://faceonlive.com/face-search-online/?utm_source={affiliate_id}`  

Replace `{affiliate_id}` with your affiliate ID.  
Example: `https://faceonlive.com/face-search-online/?utm_source=AFF12345678`  

### 2. Embed Face Search on Your Website
Attract traffic by embedding our face search widget. Affiliate IDs are automatically applied to every link.  

#### Embed as Web Component (Recommended)
```html
<script
  type="module"
  src="https://gradio.s3-us-west-2.amazonaws.com/5.5.0/gradio.js"
></script>
<gradio-app src="https://faceonlive-face-search-online.hf.space/?utm_source={affiliate_id}"></gradio-app>
```
#### Embed as iFrame
```html
<iframe
	src="https://faceonlive-face-search-online.hf.space/?utm_source={affiliate_id}"
	frameborder="0"
	width="720"
	height="1200"
></iframe>
```
Additionally, you can add checkout links below the face search widget on your website (see example on [our website](https://faceonlive.com/face-search-online/)):

- **Buy Premium Token (1 Search): $3.9**  
https://faceonlive.pocketsflow.com/checkout?productId=677fe128aeced2814bc4786e&utm_source={affiliate_id}
- **Buy Premium Token (2 Searches): $7.2**  
https://faceonlive.pocketsflow.com/checkout?productId=677fe177aeced2814bc479bc&utm_source={affiliate_id}
- **Buy Premium Token (3 Searches): $9.9**  
https://faceonlive.pocketsflow.com/checkout?productId=677fe22aaeced2814bc47bcc&utm_source={affiliate_id}
- **DMCA & GDPR Takedown Service: $9.9**  
https://faceonlive.pocketsflow.com/checkout?productId=677fe2b5aeced2814bc47dd1&utm_source={affiliate_id}

### 3. Check commission
View your commission history by entering the private key in the panel above under the "Commission History" tab.

## For any inquiries or payout requests, feel free to contact us via:

- Email: [zhu@emails.faceonlive.com](mailto:zhu@emails.faceonlive.com)
- WhatsApp: [+17074043606](https://wa.me/17074043606)
- Telegram: [t.me/faceonlive](https://t.me/faceonlive)
    """)
    gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FZhu-FaceOnLive%2FFace-Search-Affiliate"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FZhu-FaceOnLive%2FFace-Search-Affiliate&countColor=%23263759" /></a>')

    generate_btn.click(
        generate_affiliate,
        inputs=[email_input, secret_input],
        outputs=[status_output, affiliate_id_output, private_key_output],
        api_name=False
    )
    
    show_history_btn.click(
        show_commission_history,
        inputs=[private_key_input],
        outputs=[total_commission_output, commission_chart, commission_table], 
        api_name=False
    )
    app.load(on_page_load, inputs=None, outputs=aff_leaderboard_table)

app.launch(show_api=False)