Starchik1 commited on
Commit
9d307f4
·
verified ·
1 Parent(s): cea95e3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -9
main.py CHANGED
@@ -117,20 +117,14 @@ def proxy(path):
117
  # Update the link's href attribute
118
  link['href'] = google_search_url
119
 
120
- # Replace images with buttons
121
  for img in soup.find_all('img'):
122
- # Create button element
123
- button = soup.new_tag('button')
124
  img_src = img['src']
125
  if not img_src.startswith('http'):
126
  img_src = urljoin(TARGET_BASE_URL, img_src)
127
- from urllib.parse import quote
128
  proxy_url = f"/proxy_image?url={quote(img_src)}"
129
- button['onclick'] = f'window.open("{proxy_url}", "_blank")'
130
- button['style'] = 'margin: 5px;'
131
- button.string = 'Показать изображение'
132
- # Replace image with button
133
- img.replace_with(button)
134
 
135
  # Create a Flask response object with filtered content
136
  response = Response(
 
117
  # Update the link's href attribute
118
  link['href'] = google_search_url
119
 
120
+ # Update image sources to use our proxy
121
  for img in soup.find_all('img'):
 
 
122
  img_src = img['src']
123
  if not img_src.startswith('http'):
124
  img_src = urljoin(TARGET_BASE_URL, img_src)
 
125
  proxy_url = f"/proxy_image?url={quote(img_src)}"
126
+ img['src'] = proxy_url
127
+ img['style'] = 'max-width: 100%; height: auto;'
 
 
 
128
 
129
  # Create a Flask response object with filtered content
130
  response = Response(