Spaces:
Sleeping
Download LOGIN_GUIDE.md from Leospencer1/BitesizedAI: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/spaces/Leospencer1/BitesizedAI/resolve/main/LOGIN_GUIDE.md
- Command line
-
hf download hf://spaces/Leospencer1/BitesizedAI/LOGIN_GUIDE.md
-
curl -L -o LOGIN_GUIDE.md https://huggingface.co/spaces/Leospencer1/BitesizedAI/resolve/main/LOGIN_GUIDE.md
A newer version of the Gradio SDK is available: 6.32.0
π Login System & User Tracking Guide
β What I've Added:
1. Hugging Face Login System
- Users see a "π Sign in with Hugging Face" button at the top
- They log in once with their HF account (free to create)
- Their recipes are saved to their personal account
- Stays logged in across sessions
2. User Data Tracking
All user activity is automatically logged to: /mnt/user-data/users/activity_log.txt
What's tracked:
- Username
- Action (GENERATE_RECIPES, SAVE_RECIPE, VIEW_SAVED_RECIPES)
- Details (e.g., "7 meals, Β£3.50/meal")
- Timestamp
Example log entry:
2025-12-30 15:45:23 | john_smith | GENERATE_RECIPES | 7 meals, Β£3.50/meal
2025-12-30 15:48:10 | john_smith | SAVE_RECIPE | Chicken Curry
2025-12-30 16:02:45 | jane_doe | VIEW_SAVED_RECIPES |
3. Personal Recipe Storage
Each user's recipes are saved in their own folder:
/mnt/user-data/users/
βββ activity_log.txt (all users)
βββ john_smith/
β βββ recipes.pkl (John's saved recipes)
βββ jane_doe/
β βββ recipes.pkl (Jane's saved recipes)
βββ ...
π How to View Your User Data:
Option 1: Download the Activity Log
In your Hugging Face Space:
- Go to Files tab
- Navigate to
/mnt/user-data/users/ - Download
activity_log.txt - Open in Excel or text editor
Option 2: View in Code
Add this to see live stats:
# Add this at the bottom of app.py for admin view
with gr.TabItem("π Admin Stats"):
gr.Markdown("## User Activity")
def get_user_stats():
log_file = "/mnt/user-data/users/activity_log.txt"
if os.path.exists(log_file):
with open(log_file, "r") as f:
lines = f.readlines()
return f"Total actions: {len(lines)}\n\n" + "".join(lines[-20:])
return "No activity yet"
stats_text = gr.Textbox(label="Recent Activity", lines=15)
refresh_btn = gr.Button("Refresh Stats")
refresh_btn.click(get_user_stats, outputs=stats_text)
demo.load(get_user_stats, outputs=stats_text)
Option 3: Export to CSV
import pandas as pd
# Read log file
log_file = "/mnt/user-data/users/activity_log.txt"
data = []
with open(log_file, "r") as f:
for line in f:
parts = line.strip().split(" | ")
if len(parts) == 4:
data.append({
"Timestamp": parts[0],
"Username": parts[1],
"Action": parts[2],
"Details": parts[3]
})
# Create DataFrame
df = pd.DataFrame(data)
df.to_csv("user_activity.csv", index=False)
π How Users Will Experience It:
Before Login:
π½οΈ Bitesized AI Meal Planner
π€ Please log in to save recipes and track your meal plans
[π Sign in with Hugging Face]
βββββββββββββββββββββββββββββββββββββββ
[Can use app but recipes won't save]
After Login:
π½οΈ Bitesized AI Meal Planner
β
Logged in as: john_smith
[π Sign in with Hugging Face]
βββββββββββββββββββββββββββββββββββββββ
[Can use app AND save recipes permanently]
π‘ About the Info Tooltips (βΉοΈ Icons):
Good news! The info tooltips are ALREADY working as icons!
In Gradio, the info parameter shows as a small βΉοΈ icon next to the label. When users hover over it, the explanation pops up.
How they appear:
π· Cost Per Meal (Β£) βΉοΈ [dropdown]
β
When hovering here, shows: "How much you want to spend per meal. Higher = better ingredients!"
They DON'T show as full text - they're already hidden as hover-only icons! This is the default Gradio behavior.
If they're showing as full text for you, it might be:
- An older version of Gradio (update to latest)
- A browser issue (try clearing cache)
The code is already perfect - they'll show as icons for users! β
π― Summary:
β
Login added - Users sign in with HF account
β
Tracking enabled - All activity logged with username
β
Personal storage - Each user's recipes saved separately
β
Info tooltips - Already work as βΉοΈ icons (no change needed!)
π§ Following Up with Users:
To contact users:
- Download
activity_log.txt - See all usernames who used your app
- Visit their HF profiles:
https://huggingface.co/{username} - Many users have contact info or social links on their profiles
- You can also post updates in HF Discussions
Note: You get usernames only, not emails. For emails, you'd need a separate signup form (Google Forms recommended).