Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,6 @@ class URLValidator:
|
|
14 |
|
15 |
def __init__(self):
|
16 |
# SerpAPI Key
|
17 |
-
# This api key is acquired from SerpAPI website.
|
18 |
self.serpapi_key = SERPAPI_KEY
|
19 |
|
20 |
# Load models once to avoid redundant API calls
|
@@ -146,8 +145,6 @@ class URLValidator:
|
|
146 |
},
|
147 |
"explanation": explanation
|
148 |
}
|
149 |
-
st.write("LEVEL1 TITLE: APP")
|
150 |
-
st.write ("This is my first app")
|
151 |
|
152 |
# User input fields
|
153 |
user_prompt = "I have just been on an international flight, can I come back home to hold my 1-month-old newborn?"
|
@@ -155,14 +152,14 @@ url_to_check = "https://www.mayoclinic.org/healthy-lifestyle/infant-and-toddler-
|
|
155 |
|
156 |
# Run validation when the button is clicked
|
157 |
if st.button("Validate URL"):
|
158 |
-
|
159 |
-
st
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
# Display results in JSON format
|
167 |
-
st.subheader
|
168 |
-
st.
|
|
|
14 |
|
15 |
def __init__(self):
|
16 |
# SerpAPI Key
|
|
|
17 |
self.serpapi_key = SERPAPI_KEY
|
18 |
|
19 |
# Load models once to avoid redundant API calls
|
|
|
145 |
},
|
146 |
"explanation": explanation
|
147 |
}
|
|
|
|
|
148 |
|
149 |
# User input fields
|
150 |
user_prompt = "I have just been on an international flight, can I come back home to hold my 1-month-old newborn?"
|
|
|
152 |
|
153 |
# Run validation when the button is clicked
|
154 |
if st.button("Validate URL"):
|
155 |
+
if not user_prompt.strip() or not url_to_check.strip():
|
156 |
+
st.warning("Please enter both a search query and a URL.")
|
157 |
+
else:
|
158 |
+
with st.spinner("Validating URL..."):
|
159 |
+
# Instantiate the URLValidator class
|
160 |
+
validator = URLValidator()
|
161 |
+
result = validator.rate_url_validity(user_prompt, url_to_check)
|
162 |
|
163 |
# Display results in JSON format
|
164 |
+
st.subheader("Validation Results")
|
165 |
+
st.json(result)
|