User1342 commited on
Commit
3d7ef93
1 Parent(s): 4d5a231

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +100 -11
app.py CHANGED
@@ -15,12 +15,102 @@ my_access_token = os.getenv('ACCESS_TOKEN')
15
  my_access_secret = os.getenv('ACCESS_SECRET')
16
  bearer = os.getenv('BEARER')
17
 
18
- # Imports
19
- import json
20
- import os
21
- import time
22
- import gradio as gr
23
- import tweepy
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  # Setup the gradio block and add some generic CSS
26
  block = gr.Blocks(css="", title="WatchTower")
@@ -38,7 +128,7 @@ def get_client_from_tokens(oauth_verifier, oauth_token):
38
  '''
39
  new_oauth1_user_handler = tweepy.OAuth1UserHandler(
40
  consumer_token, consumer_secret,
41
- callback="https://hf.space/embed/User1342/WatchTower/"
42
  )
43
  new_oauth1_user_handler.request_token = {
44
  "oauth_token": oauth_token,
@@ -220,7 +310,7 @@ def get_target_website():
220
  '''
221
  oauth1_user_handler = tweepy.OAuth1UserHandler(
222
  consumer_token, consumer_secret,
223
- callback="https://hf.space/embed/User1342/WatchTower/"
224
  )
225
  target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
226
 
@@ -244,10 +334,10 @@ with block:
244
  user_message = "Log in via Twitter and configure your blocking options above."
245
 
246
  chat_history.append(["Welcome to Watchtower.", user_message])
247
-
248
  with gr.Group():
249
  with gr.Row().style(mobile_collapse=False, equal_height=True):
250
- gr.HTML(value=r'<img src="https://www.watchtower.cartographer.one/wp-content/uploads/2022/10/Blocking-Unfavorable-Content.png" alt="Markdown Monster icon" style="float: left; margin-right: 10px;" width="350"/>').style(
251
  )
252
  with gr.Box():
253
  #gr.Label(value="WatchTower", visible=True, interactive=False)
@@ -285,7 +375,6 @@ with block:
285
  <p style='text-align: center'>
286
  Created by <a href="https://twitter.com/_JamesStevenson" target="_blank"</a> James Stevenson
287
  <br/>
288
- <a href="https://github.com/CartographerLabs/Pinpoint" target="_blank"></a> Pinpoint GitHub
289
  </p>"""
290
  )
291
 
 
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">
26
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
27
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
28
+ <style>
29
+ body,h1,h2,h3,h4,h5 {font-family: "Poppins", sans-serif}
30
+ body {font-size: 16px;}
31
+ img {margin-bottom: -8px;}
32
+ .mySlides {display: none;}
33
+ </style>
34
+ </head>
35
+ <body class="w3-content w3-black" style="max-width:1500px;">
36
+
37
+ <!-- The App Section -->
38
+ <div class="w3-padding-64 w3-white">
39
+ <div class="w3-row-padding">
40
+ <div class="w3-col l8 m6">
41
+ <h1 class="w3-jumbo"><b>WatchTower 🐦🚧</b></h1>
42
+ <h1 class="w3-xxxlarge w3-text-orange"><b>Block Unfavorable Tweets From Your Feed </b></h1>
43
+ <p><span class="w3-xlarge">Scroll down to use WatchTower 1.0. ⬇ </span> WatchTower is a tool that identifies hate speech, misinformation, and extremist content and blocks it from your Twitter feed. WatchTower blocks content based on it's current database, so make sure to come back regullary to ensure you're up to date! WatchTower is simple to use: first scroll down the page and click the 'sign in with Twitter' button, then you'll be taken to the Twitter website and asked to verify yourself, after this you'll be taken back here, then simply scroll down to the botton of the page and click run!</p>
44
+ <a href="https://www.watchtower.cartographer.one/"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
45
+ <i class=""></i> Find Out More! 💬
46
+ </button></a>
47
+ <a href="https://ko-fi.com/jamesstevenson"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
48
+ <i class=""></i> Support The Creator! ❤
49
+ </button></a>
50
+ <a href="https://twitter.com/WATCHTOWER_WEB"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
51
+ <i class=""></i> Follow Us! 🐦
52
+ </button></a>
53
+ </div>
54
+ </div>
55
+ </div>
56
+
57
+ <!-- Modal -->
58
+ <div id="download" class="w3-modal w3-animate-opacity">
59
+ <div class="w3-modal-content" style="padding:32px">
60
+ <div class="w3-container w3-white">
61
+ <i onclick="document.getElementById('download').style.display='none'" class="fa fa-remove w3-xlarge w3-button w3-transparent w3-right w3-xlarge"></i>
62
+ <h2 class="w3-wide">DOWNLOAD</h2>
63
+ <p>Download the app in AppStore, Google Play or Microsoft Store.</p>
64
+ <i class="fa fa-android w3-large"></i> <i class="fa fa-apple w3-large"></i> <i class="fa fa-windows w3-large"></i>
65
+ <p><input class="w3-input w3-border" type="text" placeholder="Enter e-mail"></p>
66
+ <button type="button" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom" onclick="document.getElementById('download').style.display='none'">Fake Download</button>
67
+ </div>
68
+ </div>
69
+ </div>
70
+
71
+ <script>
72
+ // Slideshow
73
+ var slideIndex = 1;
74
+ showDivs(slideIndex);
75
+
76
+ function plusDivs(n) {
77
+ showDivs(slideIndex += n);
78
+ }
79
+
80
+ function showDivs(n) {
81
+ var i;
82
+ var x = document.getElementsByClassName("mySlides");
83
+ if (n > x.length) {slideIndex = 1}
84
+ if (n < 1) {slideIndex = x.length}
85
+ for (i = 0; i < x.length; i++) {
86
+ x[i].style.display = "none";
87
+ }
88
+ x[slideIndex-1].style.display = "block";
89
+ }
90
+ </script>
91
+ <br>
92
+ <br>
93
+ <br>
94
+ <br>
95
+ <br>
96
+ <br>
97
+ <br>
98
+ <br>
99
+ <br>
100
+ <br>
101
+ <br>
102
+ <br>
103
+ <br>
104
+ <br>
105
+ <br>
106
+ <br>
107
+
108
+
109
+
110
+ </body>
111
+ </html>
112
+
113
+ '''
114
 
115
  # Setup the gradio block and add some generic CSS
116
  block = gr.Blocks(css="", title="WatchTower")
 
128
  '''
129
  new_oauth1_user_handler = tweepy.OAuth1UserHandler(
130
  consumer_token, consumer_secret,
131
+ callback="http://127.0.0.1:7860/'#https://hf.space/embed/User1342/WatchTower/"
132
  )
133
  new_oauth1_user_handler.request_token = {
134
  "oauth_token": oauth_token,
 
310
  '''
311
  oauth1_user_handler = tweepy.OAuth1UserHandler(
312
  consumer_token, consumer_secret,
313
+ callback="http://127.0.0.1:7860/"#"https://hf.space/embed/User1342/WatchTower/"
314
  )
315
  target_website = oauth1_user_handler.get_authorization_url(signin_with_twitter=True)
316
 
 
334
  user_message = "Log in via Twitter and configure your blocking options above."
335
 
336
  chat_history.append(["Welcome to Watchtower.", user_message])
337
+ gr.HTML(value=html_data)
338
  with gr.Group():
339
  with gr.Row().style(mobile_collapse=False, equal_height=True):
340
+ gr.HTML(value=r'<img src="https://www.watchtower.cartographer.one/wp-content/uploads/2022/10/Blocking-Unfavorable-Content-1.png" alt="Markdown Monster icon" style="float: left; margin-right: 10px;" width="350"/>').style(
341
  )
342
  with gr.Box():
343
  #gr.Label(value="WatchTower", visible=True, interactive=False)
 
375
  <p style='text-align: center'>
376
  Created by <a href="https://twitter.com/_JamesStevenson" target="_blank"</a> James Stevenson
377
  <br/>
 
378
  </p>"""
379
  )
380