Spaces:
Sleeping
Sleeping
Mute urllib3 log messages
Browse files- helpers/image_search.py +8 -0
helpers/image_search.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
Search photos using Pexels API.
|
| 3 |
"""
|
|
|
|
| 4 |
import os
|
| 5 |
import random
|
| 6 |
from io import BytesIO
|
|
@@ -14,6 +15,13 @@ REQUEST_TIMEOUT = 12
|
|
| 14 |
MAX_PHOTOS = 2
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def search_pexels(
|
| 18 |
query: str,
|
| 19 |
size: Literal['small', 'medium', 'large'] = 'medium',
|
|
|
|
| 1 |
"""
|
| 2 |
Search photos using Pexels API.
|
| 3 |
"""
|
| 4 |
+
import logging
|
| 5 |
import os
|
| 6 |
import random
|
| 7 |
from io import BytesIO
|
|
|
|
| 15 |
MAX_PHOTOS = 2
|
| 16 |
|
| 17 |
|
| 18 |
+
# Only show warnings
|
| 19 |
+
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
| 20 |
+
# Disable all child loggers of urllib3, e.g. urllib3.connectionpool
|
| 21 |
+
logging.getLogger('urllib3').propagate = False
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
def search_pexels(
|
| 26 |
query: str,
|
| 27 |
size: Literal['small', 'medium', 'large'] = 'medium',
|