Omnibus commited on
Commit
33af16d
1 Parent(s): 74397af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -2,7 +2,7 @@
2
  from selenium import webdriver
3
 
4
  import gradio as gr
5
-
6
  import re
7
  from PIL import Image
8
  from io import BytesIO
@@ -14,6 +14,7 @@ from selenium.webdriver.common.by import By
14
  driver_type = 'chromedriver'
15
  driver=False
16
  def run_script(html: str, style: str,font_col,back_col):
 
17
  font_col=font_col.strip("#")
18
  back_col=back_col.strip("#")
19
  html = html.replace("\n","<br>")
@@ -53,7 +54,7 @@ def run_script(html: str, style: str,font_col,back_col):
53
  cookie_jar = []
54
  #cookie_jar.append(driver.get_cookies())
55
  #print(cookie_jar)
56
- screenshot = obj.screenshot('tmp.png')
57
  #screenshot = obj.get_screenshot_as_png()
58
  except WebDriverException as e:
59
  return [Image.new('RGB', (1, 1)), e, None,None]
@@ -62,7 +63,7 @@ def run_script(html: str, style: str,font_col,back_col):
62
  driver.quit()
63
 
64
  #return [Image.open(BytesIO(screenshot)), 'operation success.',cookie_jar,html]
65
- return [Image.open('tmp.png'), 'operation success.',url,html]
66
  else:
67
  return [None, 'Please enter a valid URL of a website/host.',None,None]
68
 
@@ -89,7 +90,7 @@ with gr.Blocks() as app:
89
  outim = gr.Image()
90
  with gr.Column():
91
  outp = gr.HTML()
92
- cook = gr.Textbox()
93
- html=gr.Textbox()
94
  btn.click(run_script,[inp,style,font_col,back_col],[outim,outp,cook,html])
95
  app.launch()
 
2
  from selenium import webdriver
3
 
4
  import gradio as gr
5
+ import uuid
6
  import re
7
  from PIL import Image
8
  from io import BytesIO
 
14
  driver_type = 'chromedriver'
15
  driver=False
16
  def run_script(html: str, style: str,font_col,back_col):
17
+ uid=uuid.uuid4()
18
  font_col=font_col.strip("#")
19
  back_col=back_col.strip("#")
20
  html = html.replace("\n","<br>")
 
54
  cookie_jar = []
55
  #cookie_jar.append(driver.get_cookies())
56
  #print(cookie_jar)
57
+ screenshot = obj.screenshot(f'{uid}-tmp.png')
58
  #screenshot = obj.get_screenshot_as_png()
59
  except WebDriverException as e:
60
  return [Image.new('RGB', (1, 1)), e, None,None]
 
63
  driver.quit()
64
 
65
  #return [Image.open(BytesIO(screenshot)), 'operation success.',cookie_jar,html]
66
+ return [Image.open(f'{uid}-tmp.png'), 'operation success.',url,html]
67
  else:
68
  return [None, 'Please enter a valid URL of a website/host.',None,None]
69
 
 
90
  outim = gr.Image()
91
  with gr.Column():
92
  outp = gr.HTML()
93
+ cook = gr.Textbox(label="URL")
94
+ html=gr.Textbox(visible=False)
95
  btn.click(run_script,[inp,style,font_col,back_col],[outim,outp,cook,html])
96
  app.launch()