Spaces:
Sleeping
Sleeping
Kajise
commited on
Commit
·
40b2567
1
Parent(s):
a157ab3
chore: publish local test to test env
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import gradio as Gradio
|
|
8 |
from gradio.themes.base import Base
|
9 |
from gradio.themes.utils import colors, fonts, sizes
|
10 |
|
11 |
-
|
12 |
theme = Gradio.themes.Monochrome(
|
13 |
primary_hue="purple",
|
14 |
secondary_hue="purple",
|
@@ -67,24 +66,30 @@ custom_theme = PurpleTheme()
|
|
67 |
|
68 |
title = "Imaginor"
|
69 |
driver_type = 'chromedriver'
|
70 |
-
description = "Imaginor is a small space for taking screenshots of websites
|
71 |
|
72 |
def run_imaginor(text: str):
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
return ['./site_screenshot.png', 'Website imagined by Imaginor, operation success.']
|
80 |
else:
|
81 |
-
return [None, '
|
82 |
|
83 |
Gradio.Interface(
|
84 |
run_imaginor,
|
85 |
Gradio.Textbox(placeholder="Enter your URL here", label="Website URL / Endpoint"),
|
86 |
[Gradio.Image(type="filepath", label="Screenshot"),
|
87 |
-
|
88 |
title=title,
|
89 |
description=description,
|
90 |
theme=custom_theme,
|
|
|
8 |
from gradio.themes.base import Base
|
9 |
from gradio.themes.utils import colors, fonts, sizes
|
10 |
|
|
|
11 |
theme = Gradio.themes.Monochrome(
|
12 |
primary_hue="purple",
|
13 |
secondary_hue="purple",
|
|
|
66 |
|
67 |
title = "Imaginor"
|
68 |
driver_type = 'chromedriver'
|
69 |
+
description = "<center>Imaginor is a small space for taking screenshots of websites.</center>"
|
70 |
|
71 |
def run_imaginor(text: str):
|
72 |
+
regex = r"^(https?://)"
|
73 |
+
is_url = re.search(regex, text)
|
74 |
+
|
75 |
+
if is_url:
|
76 |
+
options = webdriver.ChromeOptions()
|
77 |
+
options.add_argument("--window-size=1920,1080")
|
78 |
+
|
79 |
+
driver = webdriver.Chrome(options=options)
|
80 |
+
driver.get(text)
|
81 |
+
screenshot = driver.save_screenshot('site_screenshot.png')
|
82 |
+
driver.quit()
|
83 |
|
84 |
+
return ['site_screenshot.png', 'Website imagined by Imaginor, operation success.']
|
|
|
85 |
else:
|
86 |
+
return [None, 'Please enter a valid URL of a website/host.']
|
87 |
|
88 |
Gradio.Interface(
|
89 |
run_imaginor,
|
90 |
Gradio.Textbox(placeholder="Enter your URL here", label="Website URL / Endpoint"),
|
91 |
[Gradio.Image(type="filepath", label="Screenshot"),
|
92 |
+
Gradio.Textbox(label="Text result", interactive=False)],
|
93 |
title=title,
|
94 |
description=description,
|
95 |
theme=custom_theme,
|