Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -103,26 +103,29 @@ def on_select(space):
|
|
103 |
print(traceback.format_exc())
|
104 |
return f"오류가 발생했습니다: {str(e)}", "", Image.new('RGB', (1, 1))
|
105 |
|
106 |
-
|
107 |
def take_screenshot(url):
|
108 |
options = webdriver.ChromeOptions()
|
109 |
options.add_argument('--headless')
|
110 |
options.add_argument('--no-sandbox')
|
111 |
options.add_argument('--disable-dev-shm-usage')
|
112 |
|
|
|
113 |
try:
|
114 |
wd = webdriver.Chrome(options=options)
|
115 |
wd.set_window_size(1080, 720)
|
116 |
wd.get(url)
|
117 |
wd.implicitly_wait(10)
|
118 |
screenshot = wd.get_screenshot_as_png()
|
|
|
119 |
except WebDriverException as e:
|
|
|
|
|
|
|
|
|
120 |
return Image.new('RGB', (1, 1))
|
121 |
finally:
|
122 |
if wd:
|
123 |
wd.quit()
|
124 |
-
|
125 |
-
return Image.open(BytesIO(screenshot))
|
126 |
|
127 |
def create_ui():
|
128 |
spaces_list = get_most_liked_spaces()
|
@@ -173,6 +176,7 @@ def create_ui():
|
|
173 |
)
|
174 |
|
175 |
return demo
|
|
|
176 |
if __name__ == "__main__":
|
177 |
demo = create_ui()
|
178 |
demo.launch()
|
|
|
103 |
print(traceback.format_exc())
|
104 |
return f"오류가 발생했습니다: {str(e)}", "", Image.new('RGB', (1, 1))
|
105 |
|
|
|
106 |
def take_screenshot(url):
|
107 |
options = webdriver.ChromeOptions()
|
108 |
options.add_argument('--headless')
|
109 |
options.add_argument('--no-sandbox')
|
110 |
options.add_argument('--disable-dev-shm-usage')
|
111 |
|
112 |
+
wd = None
|
113 |
try:
|
114 |
wd = webdriver.Chrome(options=options)
|
115 |
wd.set_window_size(1080, 720)
|
116 |
wd.get(url)
|
117 |
wd.implicitly_wait(10)
|
118 |
screenshot = wd.get_screenshot_as_png()
|
119 |
+
return Image.open(BytesIO(screenshot))
|
120 |
except WebDriverException as e:
|
121 |
+
print(f"WebDriver error: {str(e)}")
|
122 |
+
return Image.new('RGB', (1, 1))
|
123 |
+
except Exception as e:
|
124 |
+
print(f"Unexpected error in take_screenshot: {str(e)}")
|
125 |
return Image.new('RGB', (1, 1))
|
126 |
finally:
|
127 |
if wd:
|
128 |
wd.quit()
|
|
|
|
|
129 |
|
130 |
def create_ui():
|
131 |
spaces_list = get_most_liked_spaces()
|
|
|
176 |
)
|
177 |
|
178 |
return demo
|
179 |
+
|
180 |
if __name__ == "__main__":
|
181 |
demo = create_ui()
|
182 |
demo.launch()
|