Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
# coding: utf-8
|
3 |
-
|
4 |
-
# Imports
|
5 |
import json
|
6 |
import os
|
|
|
7 |
import time
|
8 |
-
|
9 |
-
import
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
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 |
|
19 |
html_data = '''
|
20 |
<!DOCTYPE html>
|
@@ -117,7 +117,7 @@ def get_client_from_tokens(oauth_verifier, oauth_token):
|
|
117 |
'''
|
118 |
new_oauth1_user_handler = tweepy.OAuth1UserHandler(
|
119 |
consumer_token, consumer_secret,
|
120 |
-
callback="https://hf.space/embed/User1342/WatchTower/"
|
121 |
)
|
122 |
new_oauth1_user_handler.request_token = {
|
123 |
"oauth_token": oauth_token,
|
@@ -144,9 +144,9 @@ def get_client_from_tokens(oauth_verifier, oauth_token):
|
|
144 |
|
145 |
def block_user(user_id, user, reason):
|
146 |
finished = False
|
147 |
-
attempts = 0
|
148 |
blocked = True
|
149 |
while not finished:
|
|
|
150 |
try:
|
151 |
print("preparing to block {}".format(user_id))
|
152 |
client.block(target_user_id=user_id)
|
@@ -393,10 +393,10 @@ with block:
|
|
393 |
|
394 |
slider = gr.Slider(value=30, interactive=True, label="Threshold Confidence Tolerance")
|
395 |
|
396 |
-
chatbot = gr.Chatbot(value=chat_history, label="Watchtower Output")
|
397 |
|
398 |
-
|
399 |
-
|
400 |
)
|
401 |
btn.click(fn=button_pressed, inputs=[slider, url_params],
|
402 |
outputs=[text_output, chatbot], _js=get_window_url_params)
|
@@ -414,5 +414,5 @@ block.set_event_trigger(
|
|
414 |
event_name="load", fn=update_target_website, inputs=None, outputs=[html_button], no_target=True
|
415 |
)
|
416 |
|
417 |
-
#
|
418 |
block.launch(enable_queue = True)
|
|
|
1 |
#!/usr/bin/env python
|
2 |
# coding: utf-8
|
|
|
|
|
3 |
import json
|
4 |
import os
|
5 |
+
import re
|
6 |
import time
|
7 |
+
from random import random
|
8 |
+
import socket
|
9 |
|
10 |
+
from threading import Thread
|
11 |
+
from time import sleep
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
consumer_token = "dnzmlGXoVSuw4dFALO0gtHCtF"
|
14 |
+
consumer_secret = "SOjYOY2oOweKZTvVH6Oh0AuGex72WOcQb9O2q0LYemmRlOzD94"
|
15 |
+
my_access_token = "549478268-5QcyCYYeHoz4NuUQLt6WRBuP9cReSH8li3BsZmDn"
|
16 |
+
my_access_secret = "RC0s7rnmuDNNX3AUdb76Od3PK6w12BL5FJUTTOJeSrKxb"
|
17 |
+
bearer = "AAAAAAAAAAAAAAAAAAAAAN1mbwEAAAAAgJZWEGM9Sx76XD96L3P3cXuVz0M%3D4AXjakbASKwu86JPeoiyU0ZeO5pswTwb4InDcmzKHMmTDwW0Dr"
|
18 |
|
19 |
html_data = '''
|
20 |
<!DOCTYPE html>
|
|
|
117 |
'''
|
118 |
new_oauth1_user_handler = tweepy.OAuth1UserHandler(
|
119 |
consumer_token, consumer_secret,
|
120 |
+
callback="#https://hf.space/embed/User1342/WatchTower/"
|
121 |
)
|
122 |
new_oauth1_user_handler.request_token = {
|
123 |
"oauth_token": oauth_token,
|
|
|
144 |
|
145 |
def block_user(user_id, user, reason):
|
146 |
finished = False
|
|
|
147 |
blocked = True
|
148 |
while not finished:
|
149 |
+
attempts = 0
|
150 |
try:
|
151 |
print("preparing to block {}".format(user_id))
|
152 |
client.block(target_user_id=user_id)
|
|
|
393 |
|
394 |
slider = gr.Slider(value=30, interactive=True, label="Threshold Confidence Tolerance")
|
395 |
|
396 |
+
chatbot = gr.Chatbot(value=chat_history, label="Watchtower Output").style()
|
397 |
|
398 |
+
btn = gr.Button("Run WatchTower").style(full_width=True).style(
|
399 |
+
rounded=(True, True, True, True),
|
400 |
)
|
401 |
btn.click(fn=button_pressed, inputs=[slider, url_params],
|
402 |
outputs=[text_output, chatbot], _js=get_window_url_params)
|
|
|
414 |
event_name="load", fn=update_target_website, inputs=None, outputs=[html_button], no_target=True
|
415 |
)
|
416 |
|
417 |
+
# Launcg the page
|
418 |
block.launch(enable_queue = True)
|