Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
import re
|
| 2 |
from functools import lru_cache
|
| 3 |
-
from urllib.parse import urlparse, parse_qs
|
| 4 |
import gradio as gr
|
| 5 |
import requests
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
|
| 9 |
-
TOKEN_ERR=True
|
| 10 |
TOKEN_VALUE=os.getenv("TOKEN_VALUE")
|
| 11 |
LOGIN = os.getenv("LOGIN")
|
| 12 |
TOKEN = os.getenv("TOKEN")
|
|
@@ -233,40 +230,20 @@ def check_record(
|
|
| 233 |
|
| 234 |
return result
|
| 235 |
|
| 236 |
-
|
| 237 |
-
def generate_init(request: gr.Request):
|
| 238 |
-
global TOKEN_ERR
|
| 239 |
-
try:
|
| 240 |
-
headers =request.headers
|
| 241 |
-
url = headers.get('referer')
|
| 242 |
-
parsed_url = urlparse(url)
|
| 243 |
-
query_params = parse_qs(parsed_url.query)
|
| 244 |
-
my_dict = query_params
|
| 245 |
-
|
| 246 |
-
except KeyError as e:
|
| 247 |
-
print("Что то случилось в header", e)
|
| 248 |
-
try:
|
| 249 |
-
my_v = my_dict['v'][0]
|
| 250 |
-
if (my_v==TOKEN_VALUE):
|
| 251 |
-
TOKEN_ERR = False
|
| 252 |
-
my_v = "Token accept"
|
| 253 |
-
else : my_v = "Token error"
|
| 254 |
-
except KeyError:
|
| 255 |
-
my_v = "Token error"
|
| 256 |
-
TOKEN_ERR = True
|
| 257 |
-
return my_v
|
| 258 |
|
| 259 |
def generate(
|
| 260 |
company_code, domain, company_linkedin,
|
| 261 |
-
email, phone, contact_linkedin):
|
| 262 |
-
if
|
| 263 |
-
return check_record(
|
| 264 |
company_code=company_code,
|
| 265 |
domain=domain,
|
| 266 |
company_linkedin=company_linkedin,
|
| 267 |
email=email,
|
| 268 |
phone=phone,
|
| 269 |
contact_linkedin=contact_linkedin)
|
|
|
|
|
|
|
| 270 |
|
| 271 |
|
| 272 |
title = "NetHunt search"
|
|
@@ -283,17 +260,23 @@ with gr.Blocks(css=css, title=title) as demo:
|
|
| 283 |
)
|
| 284 |
with gr.Row():
|
| 285 |
with gr.Column():
|
|
|
|
| 286 |
input_1 = gr.Text(label="Сompany Code")
|
| 287 |
input_2 = gr.Textbox(label="Corp Domain")
|
| 288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
with gr.Column():
|
| 290 |
input_4 = gr.Textbox(label="Email")
|
| 291 |
input_5 = gr.Textbox(label="Phone")
|
| 292 |
input_6 = gr.Textbox(label="Contact LinkedIn")
|
| 293 |
-
|
|
|
|
| 294 |
output = gr.outputs.HTML()
|
| 295 |
-
input = [input_1, input_2, input_3, input_4, input_5, input_6]
|
| 296 |
greet_btn.click(fn=generate, inputs=input, outputs=output)
|
| 297 |
-
|
| 298 |
|
| 299 |
demo.launch(debug=True, share=False)
|
|
|
|
| 1 |
import re
|
| 2 |
from functools import lru_cache
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import requests
|
|
|
|
| 5 |
|
| 6 |
|
|
|
|
| 7 |
TOKEN_VALUE=os.getenv("TOKEN_VALUE")
|
| 8 |
LOGIN = os.getenv("LOGIN")
|
| 9 |
TOKEN = os.getenv("TOKEN")
|
|
|
|
| 230 |
|
| 231 |
return result
|
| 232 |
|
| 233 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
def generate(
|
| 236 |
company_code, domain, company_linkedin,
|
| 237 |
+
email, phone, contact_linkedin, token):
|
| 238 |
+
if (TOKEN_VALUE == token): return check_record(
|
|
|
|
| 239 |
company_code=company_code,
|
| 240 |
domain=domain,
|
| 241 |
company_linkedin=company_linkedin,
|
| 242 |
email=email,
|
| 243 |
phone=phone,
|
| 244 |
contact_linkedin=contact_linkedin)
|
| 245 |
+
else: return "Token error"
|
| 246 |
+
|
| 247 |
|
| 248 |
|
| 249 |
title = "NetHunt search"
|
|
|
|
| 260 |
)
|
| 261 |
with gr.Row():
|
| 262 |
with gr.Column():
|
| 263 |
+
input_7 = gr.Text(label="Token")
|
| 264 |
input_1 = gr.Text(label="Сompany Code")
|
| 265 |
input_2 = gr.Textbox(label="Corp Domain")
|
| 266 |
+
gr.Markdown("""
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
""")
|
| 270 |
+
greet_btn = gr.Button("Search")
|
| 271 |
with gr.Column():
|
| 272 |
input_4 = gr.Textbox(label="Email")
|
| 273 |
input_5 = gr.Textbox(label="Phone")
|
| 274 |
input_6 = gr.Textbox(label="Contact LinkedIn")
|
| 275 |
+
input_3 = gr.Textbox(label="Company LinkedIn")
|
| 276 |
+
|
| 277 |
output = gr.outputs.HTML()
|
| 278 |
+
input = [input_1, input_2, input_3, input_4, input_5, input_6, input_7]
|
| 279 |
greet_btn.click(fn=generate, inputs=input, outputs=output)
|
| 280 |
+
|
| 281 |
|
| 282 |
demo.launch(debug=True, share=False)
|