User1342 commited on
Commit
82e6b2b
1 Parent(s): dfafaca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -14,12 +14,10 @@ consumer_secret = os.getenv('CONSUMER_SECRET')
14
  my_access_token = os.getenv('ACCESS_TOKEN')
15
  my_access_secret = os.getenv('ACCESS_SECRET')
16
  bearer = os.getenv('BEARER')
17
-
18
  html_data = '''
19
  <!DOCTYPE html>
20
  <html>
21
  <head>
22
- <title>W3.CSS Template</title>
23
  <meta charset="UTF-8">
24
  <meta name="viewport" content="width=device-width, initial-scale=1">
25
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
@@ -112,6 +110,13 @@ function showDivs(n) {
112
 
113
  '''
114
 
 
 
 
 
 
 
 
115
  # Setup the gradio block and add some generic CSS
116
  block = gr.Blocks(css="", title="WatchTower")
117
 
@@ -128,7 +133,7 @@ def get_client_from_tokens(oauth_verifier, oauth_token):
128
  '''
129
  new_oauth1_user_handler = tweepy.OAuth1UserHandler(
130
  consumer_token, consumer_secret,
131
- callback="https://hf.space/embed/User1342/WatchTower/"
132
  )
133
  new_oauth1_user_handler.request_token = {
134
  "oauth_token": oauth_token,
@@ -310,7 +315,7 @@ def get_target_website():
310
  '''
311
  oauth1_user_handler = tweepy.OAuth1UserHandler(
312
  consumer_token, consumer_secret,
313
- callback="https://hf.space/embed/User1342/WatchTower/"
314
  )
315
  target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
316
 
@@ -320,6 +325,7 @@ def get_target_website():
320
  # The Gradio HTML component used for the 'sign in with Twitter' button
321
 
322
  # The main chunk of code that uses Gradio blocks to create the UI
 
323
  with block:
324
 
325
 
@@ -327,7 +333,6 @@ with block:
327
  <meta name="viewport" content="width=device-width, initial-scale=1">
328
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
329
  ''')
330
- gr.HTML("<center><p><br></p></center>")
331
 
332
  # todo check if user signed in
333
 
@@ -349,7 +354,7 @@ with block:
349
  text_output = gr.Text(label="Output", visible=False).style(
350
  rounded=(False, True, True, False),
351
  )
352
- twitter_auth_button = gr.HTML(
353
  value='<a href={}><img src="https://cdn.cms-twdigitalassets.com/content/dam/developer-twitter/auth-docs/sign-in-with-twitter-gray.png.twimg.1920.png" alt="Log In With Twitter"></a><br>'.format(
354
  get_target_website())).style(
355
  )
@@ -381,9 +386,8 @@ with block:
381
  # Setup callback for when page loads (used to set a new Twitter auth target webspage)
382
  block.__enter__()
383
  block.set_event_trigger(
384
- event_name="load", fn=update_target_website, inputs=None, outputs=[], no_target=True
385
  )
386
 
387
  # Launcg the page
388
- block.launch(enable_queue=False,
389
- favicon_path="https://www.jamesstevenson.me/wp-content/uploads/2022/08/Untitled-design-32.png")
 
14
  my_access_token = os.getenv('ACCESS_TOKEN')
15
  my_access_secret = os.getenv('ACCESS_SECRET')
16
  bearer = os.getenv('BEARER')
 
17
  html_data = '''
18
  <!DOCTYPE html>
19
  <html>
20
  <head>
 
21
  <meta charset="UTF-8">
22
  <meta name="viewport" content="width=device-width, initial-scale=1">
23
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
 
110
 
111
  '''
112
 
113
+ # Imports
114
+ import json
115
+ import os
116
+ import time
117
+ import gradio as gr
118
+ import tweepy
119
+
120
  # Setup the gradio block and add some generic CSS
121
  block = gr.Blocks(css="", title="WatchTower")
122
 
 
133
  '''
134
  new_oauth1_user_handler = tweepy.OAuth1UserHandler(
135
  consumer_token, consumer_secret,
136
+ callback="http://127.0.0.1:7860/'#https://hf.space/embed/User1342/WatchTower/"
137
  )
138
  new_oauth1_user_handler.request_token = {
139
  "oauth_token": oauth_token,
 
315
  '''
316
  oauth1_user_handler = tweepy.OAuth1UserHandler(
317
  consumer_token, consumer_secret,
318
+ callback="http://127.0.0.1:7860/"#"https://hf.space/embed/User1342/WatchTower/"
319
  )
320
  target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
321
 
 
325
  # The Gradio HTML component used for the 'sign in with Twitter' button
326
 
327
  # The main chunk of code that uses Gradio blocks to create the UI
328
+ html_button = None
329
  with block:
330
 
331
 
 
333
  <meta name="viewport" content="width=device-width, initial-scale=1">
334
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
335
  ''')
 
336
 
337
  # todo check if user signed in
338
 
 
354
  text_output = gr.Text(label="Output", visible=False).style(
355
  rounded=(False, True, True, False),
356
  )
357
+ html_button = twitter_auth_button = gr.HTML(
358
  value='<a href={}><img src="https://cdn.cms-twdigitalassets.com/content/dam/developer-twitter/auth-docs/sign-in-with-twitter-gray.png.twimg.1920.png" alt="Log In With Twitter"></a><br>'.format(
359
  get_target_website())).style(
360
  )
 
386
  # Setup callback for when page loads (used to set a new Twitter auth target webspage)
387
  block.__enter__()
388
  block.set_event_trigger(
389
+ event_name="load", fn=update_target_website, inputs=None, outputs=[html_button], no_target=True
390
  )
391
 
392
  # Launcg the page
393
+ block.launch(favicon_path="https://www.jamesstevenson.me/wp-content/uploads/2022/08/Untitled-design-32.png")