| |
| import streamlit as st |
| import os |
| import sys |
|
|
| |
| print("=== STARTING APP ===", file=sys.stderr) |
| print(f"Current directory: {os.getcwd()}", file=sys.stderr) |
| print(f"Files: {os.listdir('.')}", file=sys.stderr) |
|
|
| |
| if os.path.exists('.streamlit'): |
| print(f".streamlit contents: {os.listdir('.streamlit')}", file=sys.stderr) |
|
|
| |
| def main(): |
| st.set_page_config( |
| page_title="Social Media Data Extractor", |
| page_icon="๐", |
| layout="wide" |
| ) |
| |
| |
| try: |
| |
| test = st.secrets |
| print(f"Secrets loaded: {list(test.keys())}", file=sys.stderr) |
| secrets_loaded = True |
| except: |
| print("Secrets NOT loaded", file=sys.stderr) |
| secrets_loaded = False |
| |
| |
| st.title("๐ Social Media Data Extractor") |
| st.markdown("---") |
| |
| if not secrets_loaded: |
| st.error(""" |
| โ ๏ธ **Configuration Error - Secrets Not Loaded** |
| |
| **Please check:** |
| |
| 1. **HuggingFace Secrets** are configured in Space Settings |
| 2. Secret name is exactly: `STREAMLIT_SECRETS_TOML` |
| 3. The secret contains valid TOML format |
| |
| **To fix this:** |
| |
| 1. Go to your Space: https://huggingface.co/spaces/Refat81/Social_Media_Data_Extractor_Chatbot/settings |
| 2. Click "Repository secrets" |
| 3. Add a secret named: `STREAMLIT_SECRETS_TOML` |
| 4. Paste this (with your actual values): |
| |
| ```toml |
| [google] |
| client_id = "your-client-id.apps.googleusercontent.com" |
| client_secret = "your-client-secret" |
| |
| [session] |
| secret_key = "LXr9Q2v8bPp1Yt6zMk5w7x0aS3dFg4hJ7n8cV2bN5m8q9T1y3U6i0o" |
| |
| [api_keys] |
| huggingface_token = "your-hf-token" |
| ``` |
| |
| 5. Click "Save" |
| 6. Restart the Space |
| """) |
| return |
| |
| |
| try: |
| client_id = st.secrets["google"]["client_id"] |
| if client_id == "placeholder-client-id": |
| st.warning("โ ๏ธ Using placeholder credentials. Please add real Google OAuth credentials.") |
| return |
| except: |
| st.error("Google OAuth not configured in secrets") |
| return |
| |
| |
| st.markdown("### Welcome! Please login to continue") |
| |
| |
| redirect_uri = "https://refat81-social-media-data-extractor-chatbot.hf.space/oauth_callback" |
| login_url = f"https://accounts.google.com/o/oauth2/v2/auth?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code&scope=openid%20email%20profile&access_type=offline&prompt=consent" |
| |
| st.markdown(f""" |
| <a href="{login_url}" target="_self"> |
| <div style=" |
| background-color: #4285F4; |
| color: white; |
| padding: 15px 30px; |
| border-radius: 8px; |
| border: none; |
| cursor: pointer; |
| font-size: 16px; |
| font-weight: 500; |
| text-align: center; |
| margin: 20px 0; |
| display: inline-block; |
| "> |
| <img src="https://cdn-icons-png.flaticon.com/512/2991/2991148.png" width="20" height="20" style="vertical-align: middle; margin-right: 10px;"> |
| Sign in with Google |
| </div> |
| </a> |
| """, unsafe_allow_html=True) |
| |
| st.markdown("---") |
| st.info(""" |
| **Note:** First-time login might show "App not verified" warning. |
| Click "Continue" to proceed (this is normal for testing). |
| """) |
|
|
| if __name__ == "__main__": |
| main() |