raannakasturi commited on
Commit
219f61d
·
verified ·
1 Parent(s): 875e5e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -27
app.py CHANGED
@@ -1,27 +1,41 @@
1
- import sys
2
- import requests
3
- import gradio as gr
4
-
5
- def requestAPI(domain):
6
- url = f'https://ssl-checker.io/api/v1/check/{domain}'
7
- try:
8
- response = requests.get(url)
9
- except requests.exceptions.RequestException as e:
10
- print('Request failed: %s' % e)
11
- sys.exit(1)
12
- data = response.json()
13
- return data
14
-
15
- def app():
16
- with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
17
- domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
18
- data = gr.TextArea(label="Data", placeholder="Data will be displayed here", type="text", interactive=False)
19
- btn = gr.Button(value="Generate SSL Certificate")
20
- btn.click(requestAPI, inputs=domains_input, outputs=data)
21
- try:
22
- webui.queue(default_concurrency_limit=15).launch()
23
- except Exception as e:
24
- print(f"Error: {e}")
25
-
26
- if __name__ == "__main__":
27
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()