Download monetization/user_dashboard.py from mgbam/robosage: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/mgbam/robosage/resolve/1d5d1d4c40add0ffc66bdaa3654bbf88f11ea95e/monetization/user_dashboard.py
- Command line
-
hf download hf://spaces/mgbam/robosage@1d5d1d4c40add0ffc66bdaa3654bbf88f11ea95e/monetization/user_dashboard.py
-
curl -L -o user_dashboard.py https://huggingface.co/spaces/mgbam/robosage/resolve/1d5d1d4c40add0ffc66bdaa3654bbf88f11ea95e/monetization/user_dashboard.py
1.53 kB
| # user_dashboard.py - Gradio-based interface to view token usage and affiliate stats | |
| import gradio as gr | |
| from monetization.token_manager import TokenManager | |
| from monetization.affiliate_engine import get_affiliate_recommendations | |
| # Simulated app + earnings tracker | |
| USER_APPS = { | |
| "user_001": [ | |
| {"title": "WaveBot", "category": "retail", "clicks": 8, "revenue": 2.55}, | |
| {"title": "EduHelper", "category": "educational", "clicks": 13, "revenue": 5.20} | |
| ] | |
| } | |
| tm = TokenManager() | |
| tm.register_user("user_001") | |
| def dashboard_view(user_id): | |
| balance = tm.check_balance(user_id) | |
| apps = USER_APPS.get(user_id, []) | |
| total_revenue = sum(app['revenue'] for app in apps) | |
| app_display = "\n".join([f"π¦ {a['title']} ({a['category']}): ${a['revenue']:.2f} from {a['clicks']} clicks" for a in apps]) | |
| recs = get_affiliate_recommendations(apps[0]['category'] if apps else "creative") | |
| rec_display = "\n".join([f"π [{r['name']}]({r['url']})" for r in recs]) | |
| return f""" | |
| πͺ Tokens: {balance} | |
| π° Total Affiliate Revenue: ${total_revenue:.2f} | |
| **Your Apps:** | |
| {app_display} | |
| **Suggested Monetization Products:** | |
| {rec_display} | |
| """ | |
| # Launch dashboard | |
| if __name__ == "__main__": | |
| with gr.Blocks() as dash: | |
| gr.Markdown("""# π Your RoboSage Creator Dashboard""") | |
| uid = gr.Textbox(label="Enter your User ID", value="user_001") | |
| output = gr.Markdown() | |
| go = gr.Button("Load Dashboard") | |
| go.click(fn=dashboard_view, inputs=uid, outputs=output) | |
| dash.launch() | |