Skip to content

Commit

Permalink
fix path issue and allow screencap to fail without the ui failing
Browse files Browse the repository at this point in the history
  • Loading branch information
ilude committed Mar 25, 2024
1 parent f1c9d46 commit cea6cd6
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@

app = Flask(__name__)

# Create a headless browser instance
options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)

def expand_url(url):
try:
url = requests.head(url, allow_redirects=True).url

# Create a headless browser instance
options = webdriver.ChromeOptions()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)

# Navigate to the URL
driver.get(url)

# Take a screenshot of the page
driver.save_screenshot('app/assets/screenshot.png')
try:
# Take a screenshot of the page
driver.get(url)
driver.save_screenshot('app/static/screenshots/screenshot.png')
except Exception as e:
return f"Error taking screenshot: {str(e)}"

# Close the browser
driver.quit()

return url
except Exception as e:
return f"Error expanding URL: {str(e)}"
Expand Down

0 comments on commit cea6cd6

Please sign in to comment.