Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,41 @@
|
|
1 |
-
import sys
|
2 |
-
import requests
|
3 |
-
import gradio as gr
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import requests
|
3 |
+
import gradio as gr
|
4 |
+
import json
|
5 |
+
|
6 |
+
def requestAPI(domain):
|
7 |
+
url = f'https://ssl-checker.io/api/v1/check/{domain}'
|
8 |
+
try:
|
9 |
+
response = requests.get(url)
|
10 |
+
response.raise_for_status() # Raise an error for bad responses
|
11 |
+
except requests.exceptions.RequestException as e:
|
12 |
+
return {'error': f'Request failed: {e}'}
|
13 |
+
|
14 |
+
# Return the data as a JSON string
|
15 |
+
data = response.json()
|
16 |
+
return json.dumps(data, indent=2) # Format as pretty JSON
|
17 |
+
|
18 |
+
def app():
|
19 |
+
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
20 |
+
domains_input = gr.Textbox(
|
21 |
+
label="Enter Domains",
|
22 |
+
placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org",
|
23 |
+
type="text",
|
24 |
+
interactive=True
|
25 |
+
)
|
26 |
+
data = gr.TextArea(
|
27 |
+
label="Data",
|
28 |
+
placeholder="Data will be displayed here in JSON format",
|
29 |
+
type="text",
|
30 |
+
interactive=False
|
31 |
+
)
|
32 |
+
btn = gr.Button(value="Generate SSL Certificate")
|
33 |
+
btn.click(requestAPI, inputs=domains_input, outputs=data)
|
34 |
+
|
35 |
+
try:
|
36 |
+
webui.queue(default_concurrency_limit=15).launch()
|
37 |
+
except Exception as e:
|
38 |
+
print(f"Error: {e}")
|
39 |
+
|
40 |
+
if __name__ == "__main__":
|
41 |
+
app()
|