| |
| import streamlit as st |
| import os |
|
|
| def main(): |
| st.set_page_config( |
| page_title="Social Media Data Extractor", |
| page_icon="π", |
| layout="wide" |
| ) |
| |
| |
| if "authenticated" in st.session_state and st.session_state.authenticated: |
| show_dashboard() |
| else: |
| show_login_page() |
|
|
| def show_dashboard(): |
| """Show main dashboard after login""" |
| user = st.session_state.user_info |
| |
| |
| st.title(f"π Welcome, {user.get('name', 'User')}!") |
| st.write(f"Email: {user.get('email')}") |
| |
| |
| st.markdown("## π Launch Extractors") |
| |
| col1, col2, col3 = st.columns(3) |
| |
| with col1: |
| if st.button("πΌ LinkedIn Extractor", use_container_width=True): |
| st.switch_page("pages/linkedin_extractor.py") |
| |
| with col2: |
| if st.button("π Facebook Extractor", use_container_width=True): |
| st.switch_page("pages/facebook_extractor.py") |
| |
| with col3: |
| if st.button("π₯ Facebook Extractor 2.0", use_container_width=True): |
| st.switch_page("pages/facebook_extractor_pro.py") |
| |
| |
| if st.button("πͺ Logout"): |
| st.session_state.clear() |
| st.rerun() |
|
|
| def show_login_page(): |
| """Show login page""" |
| GOOGLE_CLIENT_ID = os.getenv("GOOGLE_CLIENT_ID", "") |
| |
| if not GOOGLE_CLIENT_ID: |
| st.error("Google OAuth not configured") |
| return |
| |
| st.title("π Social Media Data Extractor") |
| 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={GOOGLE_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}"> |
| <div style=" |
| background-color: #4285F4; |
| color: white; |
| padding: 15px 30px; |
| border-radius: 8px; |
| border: none; |
| cursor: pointer; |
| font-size: 18px; |
| font-weight: 600; |
| text-align: center; |
| margin: 30px 0; |
| display: inline-block; |
| "> |
| <img src="https://cdn-icons-png.flaticon.com/512/2991/2991148.png" width="24" height="24" style="vertical-align: middle; margin-right: 12px;"> |
| Sign in with Google |
| </div> |
| </a> |
| """, unsafe_allow_html=True) |
|
|
| if __name__ == "__main__": |
| main() |