Spaces:
Build error
Build error
Anil commited on
Commit ·
f3db210
1
Parent(s): 7cbe718
modified form
Browse files
app.py
CHANGED
|
@@ -1,19 +1,45 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests # For making the API call to the Lambda function
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
payload = {
|
| 12 |
-
"
|
| 13 |
"password": password
|
| 14 |
}
|
| 15 |
|
| 16 |
-
#
|
| 17 |
try:
|
| 18 |
response = requests.post(lambda_endpoint, json=payload)
|
| 19 |
response_data = response.json()
|
|
@@ -22,19 +48,18 @@ def process_email(email, password):
|
|
| 22 |
else:
|
| 23 |
return f"Error: {response_data.get('message', 'No message returned.')}"
|
| 24 |
except Exception as e:
|
| 25 |
-
return f"Failed to call
|
| 26 |
|
| 27 |
iface = gr.Interface(
|
| 28 |
-
|
| 29 |
inputs=[
|
| 30 |
-
gr.Textbox(label="Enter
|
| 31 |
gr.Textbox(label="Enter Password", type="password")
|
| 32 |
],
|
| 33 |
outputs="textbox",
|
| 34 |
live=False,
|
| 35 |
-
title="
|
| 36 |
-
description="Enter
|
| 37 |
)
|
| 38 |
|
| 39 |
-
|
| 40 |
-
iface.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests # For making the API call to the Lambda function
|
| 3 |
+
import re # For regular expression pattern matching
|
| 4 |
|
| 5 |
+
# Regular expression for domain validation
|
| 6 |
+
domain_regex = r'^(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$'
|
| 7 |
+
|
| 8 |
+
def validate_domain(domain):
|
| 9 |
+
"""Validate the domain format using regular expression."""
|
| 10 |
+
# Strip off the protocol if it's there
|
| 11 |
+
if domain.startswith("http://"):
|
| 12 |
+
domain = domain[7:]
|
| 13 |
+
elif domain.startswith("https://"):
|
| 14 |
+
domain = domain[8:]
|
| 15 |
+
elif domain.startswith("www."):
|
| 16 |
+
domain = domain[4:]
|
| 17 |
+
|
| 18 |
+
# Now validate the domain
|
| 19 |
+
if re.match(domain_regex, domain):
|
| 20 |
+
return True
|
| 21 |
+
else:
|
| 22 |
+
return False
|
| 23 |
+
|
| 24 |
+
def process_lead_search(domain, password):
|
| 25 |
+
# Validate the domain
|
| 26 |
+
|
| 27 |
+
if not validate_domain(domain):
|
| 28 |
+
return "Error: The domain format is invalid. Please enter a valid domain."
|
| 29 |
+
|
| 30 |
+
# Check if the password is not empty
|
| 31 |
+
if not password:
|
| 32 |
+
return "Error: The password cannot be empty."
|
| 33 |
+
|
| 34 |
+
lambda_endpoint = 'https://beta.nextbee.com/lib/scripts/replication_logs/index.php?db=jtaxbeta'
|
| 35 |
|
| 36 |
+
# Prepare the payload to send; ensure this matches what your Lambda function expects
|
| 37 |
payload = {
|
| 38 |
+
"domain": domain,
|
| 39 |
"password": password
|
| 40 |
}
|
| 41 |
|
| 42 |
+
# Make the POST request to the Lambda function
|
| 43 |
try:
|
| 44 |
response = requests.post(lambda_endpoint, json=payload)
|
| 45 |
response_data = response.json()
|
|
|
|
| 48 |
else:
|
| 49 |
return f"Error: {response_data.get('message', 'No message returned.')}"
|
| 50 |
except Exception as e:
|
| 51 |
+
return f"Failed to call API : {str(e)}"
|
| 52 |
|
| 53 |
iface = gr.Interface(
|
| 54 |
+
process_lead_search,
|
| 55 |
inputs=[
|
| 56 |
+
gr.Textbox(label="Enter Domain"),
|
| 57 |
gr.Textbox(label="Enter Password", type="password")
|
| 58 |
],
|
| 59 |
outputs="textbox",
|
| 60 |
live=False,
|
| 61 |
+
title="Lead Search",
|
| 62 |
+
description="Enter domain and password for processing.",
|
| 63 |
)
|
| 64 |
|
| 65 |
+
iface.launch(share=True)
|
|
|