milwright commited on
Commit
31227b8
·
1 Parent(s): 2a62deb

Update credential messaging to clarify API requirements

Browse files
Files changed (2) hide show
  1. advanced_scraper_ui.py +1 -1
  2. app.py +21 -14
advanced_scraper_ui.py CHANGED
@@ -367,7 +367,7 @@ def main():
367
  st.markdown("""
368
  ### Getting Started with Reddit Scraper
369
 
370
- 1. **Set up API credentials** in the sidebar (already pre-filled with sample credentials)
371
  2. **Enter subreddits** you want to search (one per line)
372
  3. **Enter keywords** to filter posts (one per line)
373
  4. Adjust other settings as needed
 
367
  st.markdown("""
368
  ### Getting Started with Reddit Scraper
369
 
370
+ 1. **Set up your Reddit API credentials** in the sidebar (you'll need to create these on the Reddit Developer Portal)
371
  2. **Enter subreddits** you want to search (one per line)
372
  3. **Enter keywords** to filter posts (one per line)
373
  4. Adjust other settings as needed
app.py CHANGED
@@ -63,25 +63,32 @@ from advanced_scraper_ui import main
63
 
64
  # Run the app
65
  if __name__ == "__main__":
66
- try:
67
- main()
68
- except Exception as e:
69
- st.error(f"Error: {str(e)}")
70
- st.error("This might be due to missing Reddit API credentials.")
71
 
72
- # Display instructions for setting up credentials
73
  st.markdown("""
74
- ## Setting up Reddit API Credentials
75
 
76
- This app requires Reddit API credentials to function properly. You can:
 
77
 
78
- 1. Enter your credentials directly in the sidebar when the app loads, or
79
- 2. Set them up as Hugging Face Space secrets (if you've duplicated this Space)
80
 
81
- To obtain Reddit API credentials:
82
  1. Go to https://www.reddit.com/prefs/apps
83
  2. Click "Create App" or "Create Another App"
84
- 3. Fill in the details and select "script" as the application type
85
- 4. Use "http://localhost:8000" as the redirect URI
86
- 5. Take note of the client ID and client secret
 
 
 
 
 
 
87
  """)
 
 
 
 
63
 
64
  # Run the app
65
  if __name__ == "__main__":
66
+ # Display welcome message and credential information
67
+ if not os.environ.get("REDDIT_CLIENT_ID") and not os.environ.get("REDDIT_CLIENT_SECRET"):
68
+ st.info("👋 Welcome to Reddit Scraper!")
 
 
69
 
 
70
  st.markdown("""
71
+ ## Important: Reddit API Credentials Required
72
 
73
+ This app requires you to provide your own Reddit API credentials to function.
74
+ You'll need to:
75
 
76
+ 1. Obtain your credentials from the [Reddit Developer Portal](https://www.reddit.com/prefs/apps)
77
+ 2. Enter them in the sidebar's "Reddit API Credentials" section
78
 
79
+ ### Getting Reddit API Credentials:
80
  1. Go to https://www.reddit.com/prefs/apps
81
  2. Click "Create App" or "Create Another App"
82
+ 3. Fill in the details (name, description)
83
+ 4. Select "script" as the application type
84
+ 5. Use "http://localhost:8000" as the redirect URI
85
+ 6. Click "Create app"
86
+ 7. Take note of the client ID and client secret
87
+
88
+ ### Privacy Note
89
+ Your credentials are never stored on our servers. If you're using a personal copy of this Space,
90
+ you can set them up as Space secrets for convenience.
91
  """)
92
+
93
+ # Run the main application
94
+ main()