nesticot commited on
Commit
baa7524
·
verified ·
1 Parent(s): 9f32875

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -74
app.py CHANGED
@@ -157,73 +157,6 @@ dict_pitch_alpha = dict(sorted(dict_pitch.items(), key=lambda item: item[1]))
157
 
158
  import requests
159
 
160
- import os
161
- CAMPAIGN_ID = os.getenv("CAMPAIGN_ID")
162
- ACCESS_TOKEN = os.getenv("ACCESS_TOKEN")
163
- BACKUP_PW = os.getenv("BACKUP_PW")
164
- ADMIN_PW = os.getenv("ADMIN_PW")
165
-
166
- url = f"https://www.patreon.com/api/oauth2/v2/campaigns/{CAMPAIGN_ID}/members"
167
-
168
- headers = {
169
- "Authorization": f"Bearer {ACCESS_TOKEN}"
170
- }
171
-
172
- # Simple parameters, requesting the member's email and currently entitled tiers
173
- params = {
174
- "fields[member]": "full_name,email", # Request the member's email
175
- "include": "currently_entitled_tiers", # Include the currently entitled tiers
176
- "page[size]": 10000 # Fetch up to 1000 patrons per request
177
- }
178
-
179
- response = requests.get(url, headers=headers, params=params)
180
-
181
-
182
- VALID_PASSWORDS = []
183
- if response.status_code == 200:
184
- data = response.json()
185
- for patron in data['data']:
186
- try:
187
- tiers = patron['relationships']['currently_entitled_tiers']['data']
188
- if any(tier['id'] == '9078921' for tier in tiers):
189
- full_name = patron['attributes']['email']
190
- VALID_PASSWORDS.append(full_name)
191
- except KeyError:
192
- continue
193
- VALID_PASSWORDS.append(BACKUP_PW)
194
- VALID_PASSWORDS.append(ADMIN_PW)
195
-
196
-
197
- from shiny import App, reactive, ui, render
198
- from shiny.ui import h2, tags
199
-
200
-
201
-
202
- # Define the login UI
203
- login_ui = ui.page_fluid(
204
- ui.card(
205
- ui.h2([
206
- "TJStats Daily Pitching Summary App ",
207
- ui.tags.a("(@TJStats)", href="https://twitter.com/TJStats", target="_blank")
208
- ]),
209
- ui.p(
210
- "This App is available to Superstar Patrons. Please enter your Patreon email address in the box below. If you're having trouble, please refer to the ",
211
- ui.tags.a("Patreon post", href="https://www.patreon.com/posts/122860440", target="_blank"),
212
- "."
213
- ),
214
- ui.input_password("password", "Enter Patreon Email (or Password from Link):", width="25%"),
215
- ui.tags.input(
216
- type="checkbox",
217
- id="authenticated",
218
- value=False,
219
- disabled=True
220
- ),
221
- ui.input_action_button("login", "Login", class_="btn-primary"),
222
- ui.output_text("login_message"),
223
- )
224
- )
225
-
226
-
227
  # Define the UI layout for the app
228
  main_ui = ui.page_fluid(
229
  ui.layout_sidebar(
@@ -439,14 +372,10 @@ app_ui = ui.page_fluid(
439
  ui.tags.script(src="script.js")
440
  ),
441
 
442
- ui.panel_conditional(
443
- "!input.authenticated",
444
- login_ui
445
- ),
446
- ui.panel_conditional(
447
- "input.authenticated",
448
  main_ui
449
- )
450
  )
451
 
452
 
 
157
 
158
  import requests
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  # Define the UI layout for the app
161
  main_ui = ui.page_fluid(
162
  ui.layout_sidebar(
 
372
  ui.tags.script(src="script.js")
373
  ),
374
 
375
+
376
+
 
 
 
 
377
  main_ui
378
+
379
  )
380
 
381