Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +116 -0
src/streamlit_app.py
CHANGED
|
@@ -18,6 +18,122 @@ from sklearn.feature_extraction.text import TfidfVectorizer
|
|
| 18 |
from sklearn.decomposition import LatentDirichletAllocation
|
| 19 |
from gliner import GLiNER
|
| 20 |
from streamlit_extras.stylable_container import stylable_container
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# --- Comet ML Imports (Optional/Placeholder) ---
|
| 23 |
try:
|
|
|
|
| 18 |
from sklearn.decomposition import LatentDirichletAllocation
|
| 19 |
from gliner import GLiNER
|
| 20 |
from streamlit_extras.stylable_container import stylable_container
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
import time # Optional: for simulating database processing
|
| 27 |
+
|
| 28 |
+
st.set_page_config(
|
| 29 |
+
page_title="Premium Dashboard",
|
| 30 |
+
layout="centered",
|
| 31 |
+
initial_sidebar_state="collapsed",
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# --- Email Retrieval Logic (CRITICAL) ---
|
| 35 |
+
# This is where the app reads the 'user_email' parameter from the URL
|
| 36 |
+
query_params = st.query_params
|
| 37 |
+
user_email = query_params.get("user_email")
|
| 38 |
+
|
| 39 |
+
# ----------------------------------------
|
| 40 |
+
# --- Main Application Logic ---
|
| 41 |
+
# ----------------------------------------
|
| 42 |
+
|
| 43 |
+
st.title("Premium Subscriber Dashboard")
|
| 44 |
+
st.markdown("---")
|
| 45 |
+
|
| 46 |
+
if user_email:
|
| 47 |
+
# π STEP 1: Confirmation and Display
|
| 48 |
+
st.balloons()
|
| 49 |
+
st.success(f"Payment Confirmed! Welcome to Premium, **{user_email}**! You now have full access. ")
|
| 50 |
+
|
| 51 |
+
st.header("Granting Access...")
|
| 52 |
+
|
| 53 |
+
# π STEP 2: CRITICAL BACKEND PROCESSING
|
| 54 |
+
# This is where your code would connect to your database (like Firestore)
|
| 55 |
+
# and update the user's status to 'Premium'.
|
| 56 |
+
|
| 57 |
+
with st.spinner(f"Processing subscription for {user_email}..."):
|
| 58 |
+
# --- SIMULATED DATABASE LOGIC START ---
|
| 59 |
+
time.sleep(2) # Simulate network delay/database write
|
| 60 |
+
# In a real app, you would:
|
| 61 |
+
# 1. Connect to Firestore.
|
| 62 |
+
# 2. Query your users collection to find the user with this email.
|
| 63 |
+
# 3. Update their document: { subscription_status: "active", start_date: current_date }
|
| 64 |
+
# --- SIMULATED DATABASE LOGIC END ---
|
| 65 |
+
|
| 66 |
+
st.info(f"β
Your premium access is now permanently linked to **{user_email}**.")
|
| 67 |
+
|
| 68 |
+
# π STEP 3: Display Premium Features
|
| 69 |
+
st.markdown("""
|
| 70 |
+
## π Your Exclusive Premium Features
|
| 71 |
+
""")
|
| 72 |
+
col1, col2 = st.columns(2)
|
| 73 |
+
with col1:
|
| 74 |
+
st.metric(label="Subscription Status", value="Active (Annual)")
|
| 75 |
+
with col2:
|
| 76 |
+
st.metric(label="Access Tier", value="Unlimited")
|
| 77 |
+
|
| 78 |
+
st.button("Access Advanced Reports & Tools", type="primary")
|
| 79 |
+
st.markdown("---")
|
| 80 |
+
st.write("Enjoy your enhanced experience!")
|
| 81 |
+
|
| 82 |
+
else:
|
| 83 |
+
# β οΈ Case where the user arrives without the 'user_email' parameter
|
| 84 |
+
st.error("Access Denied or Subscription Details Missing.")
|
| 85 |
+
st.markdown("""
|
| 86 |
+
It looks like you arrived here without a confirmation link. If you have already paid:
|
| 87 |
+
|
| 88 |
+
1. Please check the email address you used for payment.
|
| 89 |
+
2. Contact support with your PayPal transaction ID for manual activation.
|
| 90 |
+
|
| 91 |
+
If you have not paid, please return to the free app to upgrade.
|
| 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 |
# --- Comet ML Imports (Optional/Placeholder) ---
|
| 139 |
try:
|