Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,23 +24,22 @@ import requests
|
|
| 24 |
|
| 25 |
_msi_model = None
|
| 26 |
LOGO_PATH = "logo.png"
|
| 27 |
-
|
| 28 |
-
COUNTAPI_KEY = "images-analyzed"
|
| 29 |
|
| 30 |
|
| 31 |
def format_count_badge(count):
|
| 32 |
return (
|
| 33 |
f'<div style="background-color:#1e2761; color:white; text-align:center; '
|
| 34 |
f'padding:20px; border-radius:8px; margin-bottom:10px;">'
|
| 35 |
-
f'<div style="font-size:
|
| 36 |
-
f'<div style="font-size:20px; font-weight:bold; margin-top:8px;">{count:,} images were tested</div>'
|
| 37 |
f'</div>'
|
| 38 |
)
|
| 39 |
|
| 40 |
|
| 41 |
def get_current_count():
|
| 42 |
try:
|
| 43 |
-
resp = requests.get(f"
|
| 44 |
if resp.status_code == 200:
|
| 45 |
return resp.json().get("value", 0)
|
| 46 |
except Exception:
|
|
@@ -50,7 +49,7 @@ def get_current_count():
|
|
| 50 |
|
| 51 |
def increment_count():
|
| 52 |
try:
|
| 53 |
-
resp = requests.get(f"
|
| 54 |
if resp.status_code == 200:
|
| 55 |
return resp.json().get("value", None)
|
| 56 |
except Exception:
|
|
|
|
| 24 |
|
| 25 |
_msi_model = None
|
| 26 |
LOGO_PATH = "logo.png"
|
| 27 |
+
COUNTAPI_BASE = "https://countapi.mileshilliard.com/api/v1"
|
| 28 |
+
COUNTAPI_KEY = "haanilango-design-analyzer-images-analyzed"
|
| 29 |
|
| 30 |
|
| 31 |
def format_count_badge(count):
|
| 32 |
return (
|
| 33 |
f'<div style="background-color:#1e2761; color:white; text-align:center; '
|
| 34 |
f'padding:20px; border-radius:8px; margin-bottom:10px;">'
|
| 35 |
+
f'<div style="font-size:20px; font-weight:bold;">{count:,} images were tested</div>'
|
|
|
|
| 36 |
f'</div>'
|
| 37 |
)
|
| 38 |
|
| 39 |
|
| 40 |
def get_current_count():
|
| 41 |
try:
|
| 42 |
+
resp = requests.get(f"{COUNTAPI_BASE}/get/{COUNTAPI_KEY}", timeout=5)
|
| 43 |
if resp.status_code == 200:
|
| 44 |
return resp.json().get("value", 0)
|
| 45 |
except Exception:
|
|
|
|
| 49 |
|
| 50 |
def increment_count():
|
| 51 |
try:
|
| 52 |
+
resp = requests.get(f"{COUNTAPI_BASE}/hit/{COUNTAPI_KEY}", timeout=5)
|
| 53 |
if resp.status_code == 200:
|
| 54 |
return resp.json().get("value", None)
|
| 55 |
except Exception:
|