kfahn commited on
Commit
d914d63
·
verified ·
1 Parent(s): c67c5c8

Update app.py

Browse files

try to fix error

Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -52,7 +52,8 @@ def get_image_url(image_type: str):
52
  choices = list(image_sources.keys()) # Get all available keys
53
  best_match, score = process.extractOne(image_type, choices) # Find closest match
54
 
55
- if score > 70: # Set a threshold to ensure a reasonable match
 
56
  return image_sources[best_match]
57
  else:
58
  #return None # No good match found
@@ -80,12 +81,13 @@ async def capture_screenshot(image_type: str):
80
  page = await browser.new_page()
81
 
82
  #url = "https://openprocessing.org/sketch/2539973"
83
- url = "https://editor.p5js.org/kfahn/full/2XD5Y8MiV"
84
 
85
  if image_type:
86
  image_url = get_image_url(image_type)
87
  else:
88
- image_url = url
 
89
 
90
  print(f"Opening image from p5 sketch: {image_url}")
91
  await page.goto(image_url, timeout=120000) # Wait for the image page to load
 
52
  choices = list(image_sources.keys()) # Get all available keys
53
  best_match, score = process.extractOne(image_type, choices) # Find closest match
54
 
55
+ if score > 90: # Set a threshold to ensure a reasonable match
56
+ print(best_match)
57
  return image_sources[best_match]
58
  else:
59
  #return None # No good match found
 
81
  page = await browser.new_page()
82
 
83
  #url = "https://openprocessing.org/sketch/2539973"
84
+ #url = "https://editor.p5js.org/kfahn/full/2XD5Y8MiV"
85
 
86
  if image_type:
87
  image_url = get_image_url(image_type)
88
  else:
89
+ #image_url = url
90
+ Return "No image found"
91
 
92
  print(f"Opening image from p5 sketch: {image_url}")
93
  await page.goto(image_url, timeout=120000) # Wait for the image page to load