Omnibus commited on
Commit
f8f569b
1 Parent(s): 1d5c784

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -26
app.py CHANGED
@@ -13,11 +13,8 @@ from selenium.webdriver.common.by import By
13
 
14
  driver_type = 'chromedriver'
15
  driver=False
16
- def run_script(html: str, style: str,height,width):
17
  uid=uuid.uuid4()
18
- html = html.replace("\n","<br>")
19
- #regex = r"^(https?://)"
20
- #is_url = re.search(regex, text)
21
  is_url=True
22
  if is_url:
23
  options = webdriver.ChromeOptions()
@@ -26,8 +23,6 @@ def run_script(html: str, style: str,height,width):
26
  options.add_argument('--disable-dev-shm-usage')
27
 
28
  try:
29
-
30
- url = "https://gab.ai/c/65af72173a6a44d9799e202e"
31
  driver = webdriver.Chrome(options=options)
32
  driver.get(url)
33
  #html=driver.page_source
@@ -67,30 +62,14 @@ def run_script(html: str, style: str,height,width):
67
  else:
68
  return [None, 'Please enter a valid URL of a website/host.',None,None]
69
 
70
- html="""<h1>This is the title</h1>
71
- This is some information
72
- bla bla
73
- • a bullet
74
- • or two
75
- """
76
-
77
- sty="""height:500;width:1000;"""
78
-
79
  with gr.Blocks() as app:
80
  with gr.Row():
81
- inp = gr.Textbox(label="URL",lines=1,value=html)
82
  with gr.Column():
83
- style = gr.Textbox(label="CSS")
84
  with gr.Row():
85
  height=gr.Number(label="Height", value=4096)
86
- width=gr.Number(label="width",value=512)
87
  btn= gr.Button()
88
- with gr.Row():
89
- with gr.Column():
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,height,width],[outim,outp,cook,html])
96
  app.launch()
 
13
 
14
  driver_type = 'chromedriver'
15
  driver=False
16
+ def run_script(url: str, height: int, width: int):
17
  uid=uuid.uuid4()
 
 
 
18
  is_url=True
19
  if is_url:
20
  options = webdriver.ChromeOptions()
 
23
  options.add_argument('--disable-dev-shm-usage')
24
 
25
  try:
 
 
26
  driver = webdriver.Chrome(options=options)
27
  driver.get(url)
28
  #html=driver.page_source
 
62
  else:
63
  return [None, 'Please enter a valid URL of a website/host.',None,None]
64
 
 
 
 
 
 
 
 
 
 
65
  with gr.Blocks() as app:
66
  with gr.Row():
67
+ inp = gr.Textbox(label="URL",lines=1)
68
  with gr.Column():
 
69
  with gr.Row():
70
  height=gr.Number(label="Height", value=4096)
71
+ width=gr.Number(label="Width",value=800)
72
  btn= gr.Button()
73
+ outim = gr.Image()
74
+ btn.click(run_script,[inp,height,width],[outim,outp,cook,html])
 
 
 
 
 
 
75
  app.launch()