Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
-
import os, re, json
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
| 6 |
# ββββββββββββββββββββββββββ 1. CONFIGURATION ββββββββββββββββββββββββββ
|
| 7 |
-
DB_FILE = "favorite_sites.json" # JSON file for backward compatibility
|
| 8 |
-
SQLITE_DB = "favorite_sites.db" # SQLite database for persistence
|
| 9 |
|
| 10 |
# Domains that commonly block iframes
|
| 11 |
BLOCKED_DOMAINS = [
|
|
@@ -14,15 +12,206 @@ BLOCKED_DOMAINS = [
|
|
| 14 |
"ycombinator.com"
|
| 15 |
]
|
| 16 |
|
| 17 |
-
|
| 18 |
# ββββββββββββββββββββββββββ 2. CURATED CATEGORIES ββββββββββββββββββββββββββ
|
| 19 |
CATEGORIES = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard",
|
| 24 |
"https://huggingface.co/spaces/VIDraft/DNA-CASINO",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"https://huggingface.co/spaces/openfree/Open-GAMMA",
|
| 27 |
"https://huggingface.co/spaces/VIDraft/Robo-Beam",
|
| 28 |
"https://huggingface.co/spaces/VIDraft/voice-trans",
|
|
@@ -34,7 +223,6 @@ CATEGORIES = {
|
|
| 34 |
"https://huggingface.co/spaces/ginigen/perflexity-clone",
|
| 35 |
"https://huggingface.co/spaces/ginipick/IDEA-DESIGN",
|
| 36 |
"https://huggingface.co/spaces/ginipick/10m-marketing",
|
| 37 |
-
|
| 38 |
"https://huggingface.co/spaces/openfree/Live-Podcast",
|
| 39 |
"https://huggingface.co/spaces/openfree/AI-Podcast",
|
| 40 |
"https://huggingface.co/spaces/ginipick/QR-Canvas-plus",
|
|
@@ -47,9 +235,7 @@ CATEGORIES = {
|
|
| 47 |
"https://huggingface.co/spaces/ginipick/Change-Hair",
|
| 48 |
],
|
| 49 |
"Multimodal": [
|
| 50 |
-
|
| 51 |
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo",
|
| 52 |
-
|
| 53 |
"https://huggingface.co/spaces/fantaxy/YTB-TEST",
|
| 54 |
"https://huggingface.co/spaces/ginigen/Seedance-Free",
|
| 55 |
"https://huggingface.co/spaces/Heartsync/VEO3-RealTime",
|
|
@@ -121,7 +307,6 @@ CATEGORIES = {
|
|
| 121 |
"https://huggingface.co/spaces/openfree/VectorFlow",
|
| 122 |
"https://huggingface.co/spaces/ginigen/3D-LLAMA",
|
| 123 |
"https://huggingface.co/spaces/ginigen/Multi-LoRAgen",
|
| 124 |
-
|
| 125 |
],
|
| 126 |
"LLM / VLM": [
|
| 127 |
"https://huggingface.co/spaces/fantaxy/fantasy-novel",
|
|
@@ -142,136 +327,7 @@ CATEGORIES = {
|
|
| 142 |
],
|
| 143 |
}
|
| 144 |
|
| 145 |
-
# ββββββββββββββββββββββββββ 3.
|
| 146 |
-
def init_db():
|
| 147 |
-
# Initialize JSON file if it doesn't exist
|
| 148 |
-
if not os.path.exists(DB_FILE):
|
| 149 |
-
with open(DB_FILE, "w", encoding="utf-8") as f:
|
| 150 |
-
json.dump([], f, ensure_ascii=False)
|
| 151 |
-
|
| 152 |
-
# Initialize SQLite database
|
| 153 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 154 |
-
cursor = conn.cursor()
|
| 155 |
-
cursor.execute('''
|
| 156 |
-
CREATE TABLE IF NOT EXISTS urls (
|
| 157 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 158 |
-
url TEXT UNIQUE NOT NULL,
|
| 159 |
-
date_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
| 160 |
-
)
|
| 161 |
-
''')
|
| 162 |
-
conn.commit()
|
| 163 |
-
|
| 164 |
-
# If we have data in JSON but not in SQLite (first run with new SQLite DB),
|
| 165 |
-
# migrate the data from JSON to SQLite
|
| 166 |
-
json_urls = load_json()
|
| 167 |
-
if json_urls:
|
| 168 |
-
db_urls = load_db_sqlite()
|
| 169 |
-
for url in json_urls:
|
| 170 |
-
if url not in db_urls:
|
| 171 |
-
add_url_to_sqlite(url)
|
| 172 |
-
|
| 173 |
-
conn.close()
|
| 174 |
-
|
| 175 |
-
def load_json():
|
| 176 |
-
"""Load URLs from JSON file (for backward compatibility)"""
|
| 177 |
-
try:
|
| 178 |
-
with open(DB_FILE, "r", encoding="utf-8") as f:
|
| 179 |
-
raw = json.load(f)
|
| 180 |
-
return raw if isinstance(raw, list) else []
|
| 181 |
-
except Exception:
|
| 182 |
-
return []
|
| 183 |
-
|
| 184 |
-
def save_json(lst):
|
| 185 |
-
"""Save URLs to JSON file (for backward compatibility)"""
|
| 186 |
-
try:
|
| 187 |
-
with open(DB_FILE, "w", encoding="utf-8") as f:
|
| 188 |
-
json.dump(lst, f, ensure_ascii=False, indent=2)
|
| 189 |
-
return True
|
| 190 |
-
except Exception:
|
| 191 |
-
return False
|
| 192 |
-
|
| 193 |
-
def load_db_sqlite():
|
| 194 |
-
"""Load URLs from SQLite database"""
|
| 195 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 196 |
-
cursor = conn.cursor()
|
| 197 |
-
cursor.execute("SELECT url FROM urls ORDER BY date_added DESC")
|
| 198 |
-
urls = [row[0] for row in cursor.fetchall()]
|
| 199 |
-
conn.close()
|
| 200 |
-
return urls
|
| 201 |
-
|
| 202 |
-
def add_url_to_sqlite(url):
|
| 203 |
-
"""Add a URL to SQLite database"""
|
| 204 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 205 |
-
cursor = conn.cursor()
|
| 206 |
-
try:
|
| 207 |
-
cursor.execute("INSERT INTO urls (url) VALUES (?)", (url,))
|
| 208 |
-
conn.commit()
|
| 209 |
-
success = True
|
| 210 |
-
except sqlite3.IntegrityError:
|
| 211 |
-
# URL already exists
|
| 212 |
-
success = False
|
| 213 |
-
conn.close()
|
| 214 |
-
return success
|
| 215 |
-
|
| 216 |
-
def update_url_in_sqlite(old_url, new_url):
|
| 217 |
-
"""Update a URL in SQLite database"""
|
| 218 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 219 |
-
cursor = conn.cursor()
|
| 220 |
-
try:
|
| 221 |
-
cursor.execute("UPDATE urls SET url = ? WHERE url = ?", (new_url, old_url))
|
| 222 |
-
if cursor.rowcount > 0:
|
| 223 |
-
conn.commit()
|
| 224 |
-
success = True
|
| 225 |
-
else:
|
| 226 |
-
success = False
|
| 227 |
-
except sqlite3.IntegrityError:
|
| 228 |
-
# New URL already exists
|
| 229 |
-
success = False
|
| 230 |
-
conn.close()
|
| 231 |
-
return success
|
| 232 |
-
|
| 233 |
-
def delete_url_from_sqlite(url):
|
| 234 |
-
"""Delete a URL from SQLite database"""
|
| 235 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 236 |
-
cursor = conn.cursor()
|
| 237 |
-
cursor.execute("DELETE FROM urls WHERE url = ?", (url,))
|
| 238 |
-
if cursor.rowcount > 0:
|
| 239 |
-
conn.commit()
|
| 240 |
-
success = True
|
| 241 |
-
else:
|
| 242 |
-
success = False
|
| 243 |
-
conn.close()
|
| 244 |
-
return success
|
| 245 |
-
|
| 246 |
-
def load_db():
|
| 247 |
-
"""Primary function to load URLs - prioritizes SQLite DB but falls back to JSON"""
|
| 248 |
-
urls = load_db_sqlite()
|
| 249 |
-
if not urls:
|
| 250 |
-
# If SQLite DB is empty, try loading from JSON
|
| 251 |
-
urls = load_json()
|
| 252 |
-
# If we found URLs in JSON, migrate them to SQLite
|
| 253 |
-
for url in urls:
|
| 254 |
-
add_url_to_sqlite(url)
|
| 255 |
-
return urls
|
| 256 |
-
|
| 257 |
-
def save_db(lst):
|
| 258 |
-
"""Save URLs to both SQLite and JSON"""
|
| 259 |
-
# Get existing URLs from SQLite for comparison
|
| 260 |
-
existing_urls = load_db_sqlite()
|
| 261 |
-
|
| 262 |
-
# Clear all URLs from SQLite and add the new list
|
| 263 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 264 |
-
cursor = conn.cursor()
|
| 265 |
-
cursor.execute("DELETE FROM urls")
|
| 266 |
-
for url in lst:
|
| 267 |
-
cursor.execute("INSERT INTO urls (url) VALUES (?)", (url,))
|
| 268 |
-
conn.commit()
|
| 269 |
-
conn.close()
|
| 270 |
-
|
| 271 |
-
# Also save to JSON for backward compatibility
|
| 272 |
-
return save_json(lst)
|
| 273 |
-
|
| 274 |
-
# ββββββββββββββββββββββββββ 4. URL HELPERS ββββββββββββββββββββββββββ
|
| 275 |
def direct_url(hf_url):
|
| 276 |
m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", hf_url)
|
| 277 |
if not m:
|
|
@@ -309,15 +365,15 @@ def process_url_for_preview(url):
|
|
| 309 |
# Default handling
|
| 310 |
return url, "iframe"
|
| 311 |
|
| 312 |
-
# ββββββββββββββββββββββββββ
|
| 313 |
@app.route('/api/category')
|
| 314 |
def api_category():
|
| 315 |
cat = request.args.get('name', '')
|
| 316 |
urls = CATEGORIES.get(cat, [])
|
| 317 |
|
| 318 |
-
# Add pagination for categories
|
| 319 |
page = int(request.args.get('page', 1))
|
| 320 |
-
per_page = int(request.args.get('per_page', 4))
|
| 321 |
|
| 322 |
total_pages = max(1, (len(urls) + per_page - 1) // per_page)
|
| 323 |
start = (page - 1) * per_page
|
|
@@ -341,122 +397,7 @@ def api_category():
|
|
| 341 |
"total_pages": total_pages
|
| 342 |
})
|
| 343 |
|
| 344 |
-
|
| 345 |
-
def api_favorites():
|
| 346 |
-
# Load URLs from SQLite database
|
| 347 |
-
urls = load_db()
|
| 348 |
-
|
| 349 |
-
page = int(request.args.get('page', 1))
|
| 350 |
-
per_page = int(request.args.get('per_page', 4)) # Changed to 4 per page
|
| 351 |
-
|
| 352 |
-
total_pages = max(1, (len(urls) + per_page - 1) // per_page)
|
| 353 |
-
start = (page - 1) * per_page
|
| 354 |
-
end = min(start + per_page, len(urls))
|
| 355 |
-
|
| 356 |
-
urls_page = urls[start:end]
|
| 357 |
-
|
| 358 |
-
result = []
|
| 359 |
-
for url in urls_page:
|
| 360 |
-
try:
|
| 361 |
-
preview_url, mode = process_url_for_preview(url)
|
| 362 |
-
result.append({
|
| 363 |
-
"title": url.split('/')[-1],
|
| 364 |
-
"url": url,
|
| 365 |
-
"preview_url": preview_url,
|
| 366 |
-
"mode": mode
|
| 367 |
-
})
|
| 368 |
-
except Exception:
|
| 369 |
-
# Fallback to screenshot mode
|
| 370 |
-
result.append({
|
| 371 |
-
"title": url.split('/')[-1],
|
| 372 |
-
"url": url,
|
| 373 |
-
"preview_url": screenshot_url(url),
|
| 374 |
-
"mode": "snapshot"
|
| 375 |
-
})
|
| 376 |
-
|
| 377 |
-
return jsonify({
|
| 378 |
-
"items": result,
|
| 379 |
-
"page": page,
|
| 380 |
-
"total_pages": total_pages
|
| 381 |
-
})
|
| 382 |
-
|
| 383 |
-
@app.route('/api/url/add', methods=['POST'])
|
| 384 |
-
def add_url():
|
| 385 |
-
url = request.form.get('url', '').strip()
|
| 386 |
-
if not url:
|
| 387 |
-
return jsonify({"success": False, "message": "URL is required"})
|
| 388 |
-
|
| 389 |
-
# SQLiteμ μΆκ° μλ
|
| 390 |
-
conn = sqlite3.connect(SQLITE_DB)
|
| 391 |
-
cursor = conn.cursor()
|
| 392 |
-
try:
|
| 393 |
-
cursor.execute("INSERT INTO urls (url) VALUES (?)", (url,))
|
| 394 |
-
conn.commit()
|
| 395 |
-
success = True
|
| 396 |
-
except sqlite3.IntegrityError:
|
| 397 |
-
# URLμ΄ μ΄λ―Έ μ‘΄μ¬νλ κ²½μ°
|
| 398 |
-
success = False
|
| 399 |
-
except Exception as e:
|
| 400 |
-
print(f"SQLite error: {str(e)}")
|
| 401 |
-
success = False
|
| 402 |
-
finally:
|
| 403 |
-
conn.close()
|
| 404 |
-
|
| 405 |
-
if not success:
|
| 406 |
-
return jsonify({"success": False, "message": "URL already exists or could not be added"})
|
| 407 |
-
|
| 408 |
-
# JSON νμΌμλ μΆκ° (λ°±μ
μ©)
|
| 409 |
-
data = load_json()
|
| 410 |
-
if url not in data:
|
| 411 |
-
data.insert(0, url)
|
| 412 |
-
save_json(data)
|
| 413 |
-
|
| 414 |
-
return jsonify({"success": True, "message": "URL added successfully"})
|
| 415 |
-
|
| 416 |
-
@app.route('/api/url/update', methods=['POST'])
|
| 417 |
-
def update_url():
|
| 418 |
-
old = request.form.get('old', '')
|
| 419 |
-
new = request.form.get('new', '').strip()
|
| 420 |
-
|
| 421 |
-
if not new:
|
| 422 |
-
return jsonify({"success": False, "message": "New URL is required"})
|
| 423 |
-
|
| 424 |
-
# Update in SQLite DB
|
| 425 |
-
if not update_url_in_sqlite(old, new):
|
| 426 |
-
return jsonify({"success": False, "message": "URL not found or new URL already exists"})
|
| 427 |
-
|
| 428 |
-
# Also update JSON file for backward compatibility
|
| 429 |
-
data = load_json()
|
| 430 |
-
try:
|
| 431 |
-
idx = data.index(old)
|
| 432 |
-
data[idx] = new
|
| 433 |
-
save_json(data)
|
| 434 |
-
except ValueError:
|
| 435 |
-
# If URL not in JSON, add it
|
| 436 |
-
data.append(new)
|
| 437 |
-
save_json(data)
|
| 438 |
-
|
| 439 |
-
return jsonify({"success": True, "message": "URL updated successfully"})
|
| 440 |
-
|
| 441 |
-
@app.route('/api/url/delete', methods=['POST'])
|
| 442 |
-
def delete_url():
|
| 443 |
-
url = request.form.get('url', '')
|
| 444 |
-
|
| 445 |
-
# Delete from SQLite DB
|
| 446 |
-
if not delete_url_from_sqlite(url):
|
| 447 |
-
return jsonify({"success": False, "message": "URL not found"})
|
| 448 |
-
|
| 449 |
-
# Also update JSON file for backward compatibility
|
| 450 |
-
data = load_json()
|
| 451 |
-
try:
|
| 452 |
-
data.remove(url)
|
| 453 |
-
save_json(data)
|
| 454 |
-
except ValueError:
|
| 455 |
-
pass
|
| 456 |
-
|
| 457 |
-
return jsonify({"success": True, "message": "URL deleted successfully"})
|
| 458 |
-
|
| 459 |
-
# ββββββββββββββββββββββββββ 6. MAIN ROUTES ββββββββββββββββββββββββββ
|
| 460 |
@app.route('/')
|
| 461 |
def home():
|
| 462 |
os.makedirs('templates', exist_ok=True)
|
|
@@ -474,8 +415,12 @@ body{margin:0;font-family:Nunito,sans-serif;background:#f6f8fb;}
|
|
| 474 |
.tabs{display:flex;flex-wrap:wrap;gap:8px;padding:16px;}
|
| 475 |
.tab{padding:6px 14px;border:none;border-radius:18px;background:#e2e8f0;font-weight:600;cursor:pointer;}
|
| 476 |
.tab.active{background:#a78bfa;color:#1a202c;}
|
| 477 |
-
.tab.
|
| 478 |
-
.tab.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
/* Updated grid to show 2x2 layout */
|
| 480 |
.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:20px;padding:0 16px 60px;max-width:1200px;margin:0 auto;}
|
| 481 |
@media(max-width:800px){.grid{grid-template-columns:1fr;}}
|
|
@@ -492,29 +437,16 @@ body{margin:0;font-family:Nunito,sans-serif;background:#f6f8fb;}
|
|
| 492 |
.pagination{display:flex;justify-content:center;margin:20px 0;gap:10px;}
|
| 493 |
.pagination button{padding:5px 15px;border:none;border-radius:20px;background:#e2e8f0;cursor:pointer;}
|
| 494 |
.pagination button:disabled{opacity:0.5;cursor:not-allowed;}
|
| 495 |
-
.manage-panel{background:white;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,.08);margin:16px;padding:20px;}
|
| 496 |
-
.form-group{margin-bottom:15px;}
|
| 497 |
-
.form-group label{display:block;margin-bottom:5px;font-weight:600;}
|
| 498 |
-
.form-control{width:100%;padding:8px;border:1px solid #ddd;border-radius:4px;box-sizing:border-box;}
|
| 499 |
-
.btn{padding:8px 15px;border:none;border-radius:4px;cursor:pointer;font-weight:600;}
|
| 500 |
-
.btn-primary{background:#4a6dd8;color:white;}
|
| 501 |
-
.btn-danger{background:#e53e3e;color:white;}
|
| 502 |
-
.btn-success{background:#38a169;color:white;}
|
| 503 |
-
.status{padding:10px;margin:10px 0;border-radius:4px;display:none;}
|
| 504 |
-
.status.success{display:block;background:#c6f6d5;color:#22543d;}
|
| 505 |
-
.status.error{display:block;background:#fed7d7;color:#822727;}
|
| 506 |
-
.url-list{margin:20px 0;border:1px solid #eee;border-radius:4px;max-height:300px;overflow-y:auto;}
|
| 507 |
-
.url-item{padding:10px;border-bottom:1px solid #eee;display:flex;justify-content:space-between;align-items:center;}
|
| 508 |
-
.url-item:last-child{border-bottom:none;}
|
| 509 |
-
.url-controls{display:flex;gap:5px;}
|
| 510 |
</style>
|
| 511 |
</head>
|
| 512 |
<body>
|
| 513 |
<header style="text-align: center; padding: 20px; background: linear-gradient(135deg, #f6f8fb, #e2e8f0); border-bottom: 1px solid #ddd;">
|
| 514 |
-
<h1 style="margin-bottom: 10px;">πAI Playground</h1>
|
| 515 |
<p>
|
|
|
|
| 516 |
<a href="https://discord.gg/openfreeai" target="_blank"><img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="badge"></a>
|
| 517 |
-
|
|
|
|
| 518 |
</header>
|
| 519 |
<div class="tabs" id="tabs"></div>
|
| 520 |
<div id="content"></div>
|
|
@@ -528,17 +460,6 @@ let active = "";
|
|
| 528 |
let currentPage = 1;
|
| 529 |
|
| 530 |
// Simple utility functions
|
| 531 |
-
function loadHTML(url, callback) {
|
| 532 |
-
const xhr = new XMLHttpRequest();
|
| 533 |
-
xhr.open('GET', url, true);
|
| 534 |
-
xhr.onreadystatechange = function() {
|
| 535 |
-
if (xhr.readyState === 4 && xhr.status === 200) {
|
| 536 |
-
callback(xhr.responseText);
|
| 537 |
-
}
|
| 538 |
-
};
|
| 539 |
-
xhr.send();
|
| 540 |
-
}
|
| 541 |
-
|
| 542 |
function makeRequest(url, method, data, callback) {
|
| 543 |
const xhr = new XMLHttpRequest();
|
| 544 |
xhr.open(method, url, true);
|
|
@@ -605,224 +526,31 @@ function loadCategory(cat, page) {
|
|
| 605 |
});
|
| 606 |
}
|
| 607 |
|
| 608 |
-
function loadFavorites(page) {
|
| 609 |
-
if(active === 'Favorites' && currentPage === page) return;
|
| 610 |
-
active = 'Favorites';
|
| 611 |
-
currentPage = page || 1;
|
| 612 |
-
updateTabs();
|
| 613 |
-
|
| 614 |
-
content.innerHTML = '<p style="text-align:center;padding:40px">Loadingβ¦</p>';
|
| 615 |
-
|
| 616 |
-
makeRequest('/api/favorites?page=' + currentPage + '&per_page=4', 'GET', null, function(data) {
|
| 617 |
-
let html = '<div class="grid">';
|
| 618 |
-
|
| 619 |
-
if(data.items.length === 0) {
|
| 620 |
-
html += '<p style="grid-column:1/-1;text-align:center;padding:40px">No favorites saved yet.</p>';
|
| 621 |
-
} else {
|
| 622 |
-
data.items.forEach(item => {
|
| 623 |
-
if(item.mode === 'snapshot') {
|
| 624 |
-
html += `
|
| 625 |
-
<div class="card">
|
| 626 |
-
<div class="card-label label-static">Static</div>
|
| 627 |
-
<div class="frame">
|
| 628 |
-
<img src="${item.preview_url}" loading="lazy">
|
| 629 |
-
</div>
|
| 630 |
-
<div class="foot">
|
| 631 |
-
<a href="${item.url}" target="_blank">${item.title}</a>
|
| 632 |
-
</div>
|
| 633 |
-
</div>
|
| 634 |
-
`;
|
| 635 |
-
} else {
|
| 636 |
-
html += `
|
| 637 |
-
<div class="card">
|
| 638 |
-
<div class="card-label label-live">LIVE</div>
|
| 639 |
-
<div class="frame">
|
| 640 |
-
<iframe src="${item.preview_url}" loading="lazy" sandbox="allow-forms allow-modals allow-popups allow-same-origin allow-scripts allow-downloads"></iframe>
|
| 641 |
-
</div>
|
| 642 |
-
<div class="foot">
|
| 643 |
-
<a href="${item.url}" target="_blank">${item.title}</a>
|
| 644 |
-
</div>
|
| 645 |
-
</div>
|
| 646 |
-
`;
|
| 647 |
-
}
|
| 648 |
-
});
|
| 649 |
-
}
|
| 650 |
-
|
| 651 |
-
html += '</div>';
|
| 652 |
-
|
| 653 |
-
// Add pagination
|
| 654 |
-
html += `
|
| 655 |
-
<div class="pagination">
|
| 656 |
-
<button ${currentPage <= 1 ? 'disabled' : ''} onclick="loadFavorites(${currentPage-1})">Β« Previous</button>
|
| 657 |
-
<span>Page ${currentPage} of ${data.total_pages}</span>
|
| 658 |
-
<button ${currentPage >= data.total_pages ? 'disabled' : ''} onclick="loadFavorites(${currentPage+1})">Next Β»</button>
|
| 659 |
-
</div>
|
| 660 |
-
`;
|
| 661 |
-
|
| 662 |
-
content.innerHTML = html;
|
| 663 |
-
});
|
| 664 |
-
}
|
| 665 |
-
|
| 666 |
-
function loadManage() {
|
| 667 |
-
if(active === 'Manage') return;
|
| 668 |
-
active = 'Manage';
|
| 669 |
-
updateTabs();
|
| 670 |
-
|
| 671 |
-
content.innerHTML = `
|
| 672 |
-
<div class="manage-panel">
|
| 673 |
-
<h2>Add New URL</h2>
|
| 674 |
-
<div class="form-group">
|
| 675 |
-
<label for="new-url">URL</label>
|
| 676 |
-
<input type="text" id="new-url" class="form-control" placeholder="https://example.com">
|
| 677 |
-
</div>
|
| 678 |
-
<button onclick="addUrl()" class="btn btn-primary">Add URL</button>
|
| 679 |
-
<div id="add-status" class="status"></div>
|
| 680 |
-
|
| 681 |
-
<h2>Manage Saved URLs</h2>
|
| 682 |
-
<div id="url-list" class="url-list">Loading...</div>
|
| 683 |
-
</div>
|
| 684 |
-
`;
|
| 685 |
-
|
| 686 |
-
loadUrlList();
|
| 687 |
-
}
|
| 688 |
-
|
| 689 |
-
// URL management functions
|
| 690 |
-
function loadUrlList() {
|
| 691 |
-
makeRequest('/api/favorites?per_page=100', 'GET', null, function(data) {
|
| 692 |
-
const urlList = document.getElementById('url-list');
|
| 693 |
-
|
| 694 |
-
if(data.items.length === 0) {
|
| 695 |
-
urlList.innerHTML = '<p style="text-align:center;padding:20px">No URLs saved yet.</p>';
|
| 696 |
-
return;
|
| 697 |
-
}
|
| 698 |
-
|
| 699 |
-
let html = '';
|
| 700 |
-
data.items.forEach(item => {
|
| 701 |
-
// Escape the URL to prevent JavaScript injection when used in onclick handlers
|
| 702 |
-
const escapedUrl = item.url.replace(/'/g, "\\'");
|
| 703 |
-
|
| 704 |
-
html += `
|
| 705 |
-
<div class="url-item">
|
| 706 |
-
<div>${item.url}</div>
|
| 707 |
-
<div class="url-controls">
|
| 708 |
-
<button class="btn" onclick="editUrl('${escapedUrl}')">Edit</button>
|
| 709 |
-
<button class="btn btn-danger" onclick="deleteUrl('${escapedUrl}')">Delete</button>
|
| 710 |
-
</div>
|
| 711 |
-
</div>
|
| 712 |
-
`;
|
| 713 |
-
});
|
| 714 |
-
|
| 715 |
-
urlList.innerHTML = html;
|
| 716 |
-
});
|
| 717 |
-
}
|
| 718 |
-
|
| 719 |
-
function addUrl() {
|
| 720 |
-
const url = document.getElementById('new-url').value.trim();
|
| 721 |
-
|
| 722 |
-
if(!url) {
|
| 723 |
-
showStatus('add-status', 'Please enter a URL', false);
|
| 724 |
-
return;
|
| 725 |
-
}
|
| 726 |
-
|
| 727 |
-
const formData = new FormData();
|
| 728 |
-
formData.append('url', url);
|
| 729 |
-
|
| 730 |
-
makeRequest('/api/url/add', 'POST', formData, function(data) {
|
| 731 |
-
showStatus('add-status', data.message, data.success);
|
| 732 |
-
if(data.success) {
|
| 733 |
-
document.getElementById('new-url').value = '';
|
| 734 |
-
loadUrlList();
|
| 735 |
-
// If currently in Favorites tab, reload to see changes immediately
|
| 736 |
-
if(active === 'Favorites') {
|
| 737 |
-
loadFavorites(currentPage);
|
| 738 |
-
}
|
| 739 |
-
}
|
| 740 |
-
});
|
| 741 |
-
}
|
| 742 |
-
|
| 743 |
-
function editUrl(url) {
|
| 744 |
-
// Decode URL if it was previously escaped
|
| 745 |
-
const decodedUrl = url.replace(/\\'/g, "'");
|
| 746 |
-
const newUrl = prompt('Edit URL:', decodedUrl);
|
| 747 |
-
|
| 748 |
-
if(!newUrl || newUrl === decodedUrl) return;
|
| 749 |
-
|
| 750 |
-
const formData = new FormData();
|
| 751 |
-
formData.append('old', decodedUrl);
|
| 752 |
-
formData.append('new', newUrl);
|
| 753 |
-
|
| 754 |
-
makeRequest('/api/url/update', 'POST', formData, function(data) {
|
| 755 |
-
if(data.success) {
|
| 756 |
-
loadUrlList();
|
| 757 |
-
// If currently in Favorites tab, reload to see changes immediately
|
| 758 |
-
if(active === 'Favorites') {
|
| 759 |
-
loadFavorites(currentPage);
|
| 760 |
-
}
|
| 761 |
-
} else {
|
| 762 |
-
alert(data.message);
|
| 763 |
-
}
|
| 764 |
-
});
|
| 765 |
-
}
|
| 766 |
-
|
| 767 |
-
function deleteUrl(url) {
|
| 768 |
-
// Decode URL if it was previously escaped
|
| 769 |
-
const decodedUrl = url.replace(/\\'/g, "'");
|
| 770 |
-
if(!confirm('Are you sure you want to delete this URL?')) return;
|
| 771 |
-
|
| 772 |
-
const formData = new FormData();
|
| 773 |
-
formData.append('url', decodedUrl);
|
| 774 |
-
|
| 775 |
-
makeRequest('/api/url/delete', 'POST', formData, function(data) {
|
| 776 |
-
if(data.success) {
|
| 777 |
-
loadUrlList();
|
| 778 |
-
// If currently in Favorites tab, reload to see changes immediately
|
| 779 |
-
if(active === 'Favorites') {
|
| 780 |
-
loadFavorites(currentPage);
|
| 781 |
-
}
|
| 782 |
-
} else {
|
| 783 |
-
alert(data.message);
|
| 784 |
-
}
|
| 785 |
-
});
|
| 786 |
-
}
|
| 787 |
-
|
| 788 |
-
function showStatus(id, message, success) {
|
| 789 |
-
const status = document.getElementById(id);
|
| 790 |
-
status.textContent = message;
|
| 791 |
-
status.className = success ? 'status success' : 'status error';
|
| 792 |
-
setTimeout(() => {
|
| 793 |
-
status.className = 'status';
|
| 794 |
-
}, 3000);
|
| 795 |
-
}
|
| 796 |
-
|
| 797 |
// Create tabs
|
| 798 |
-
//
|
| 799 |
-
|
| 800 |
-
favTab.className = 'tab';
|
| 801 |
-
favTab.textContent = 'Favorites';
|
| 802 |
-
favTab.dataset.c = 'Favorites';
|
| 803 |
-
favTab.onclick = function() { loadFavorites(1); };
|
| 804 |
-
tabs.appendChild(favTab);
|
| 805 |
-
|
| 806 |
-
// Category tabs
|
| 807 |
-
cats.forEach(c => {
|
| 808 |
const b = document.createElement('button');
|
| 809 |
-
b.className = 'tab';
|
| 810 |
-
b.textContent =
|
| 811 |
-
b.dataset.c =
|
| 812 |
-
b.onclick = function() { loadCategory(
|
| 813 |
tabs.appendChild(b);
|
| 814 |
});
|
| 815 |
|
| 816 |
-
//
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
|
| 824 |
-
// Start with
|
| 825 |
-
|
| 826 |
</script>
|
| 827 |
</body>
|
| 828 |
</html>''')
|
|
@@ -830,34 +558,5 @@ loadFavorites(1);
|
|
| 830 |
# Return the rendered template
|
| 831 |
return render_template('index.html', cats=list(CATEGORIES.keys()))
|
| 832 |
|
| 833 |
-
# Initialize database on startup
|
| 834 |
-
init_db()
|
| 835 |
-
|
| 836 |
-
# Define a function to ensure database consistency
|
| 837 |
-
def ensure_db_consistency():
|
| 838 |
-
# Make sure we have the latest data in both JSON and SQLite
|
| 839 |
-
urls = load_db_sqlite()
|
| 840 |
-
save_json(urls)
|
| 841 |
-
|
| 842 |
-
# For Flask 2.0+ compatibility
|
| 843 |
-
@app.before_request
|
| 844 |
-
def before_request_func():
|
| 845 |
-
# Use a flag to run this only once
|
| 846 |
-
if not hasattr(app, '_got_first_request'):
|
| 847 |
-
ensure_db_consistency()
|
| 848 |
-
app._got_first_request = True
|
| 849 |
-
|
| 850 |
if __name__ == '__main__':
|
| 851 |
-
# μ± μμ μ μ λͺ
μμ μΌλ‘ DB μ΄κΈ°ν
|
| 852 |
-
print("Initializing database...")
|
| 853 |
-
init_db()
|
| 854 |
-
|
| 855 |
-
# λ°μ΄ν°λ² μ΄μ€ νμΌ κ²½λ‘ λ° μ‘΄μ¬ μ¬λΆ νμΈ
|
| 856 |
-
db_path = os.path.abspath(SQLITE_DB)
|
| 857 |
-
print(f"SQLite DB path: {db_path}")
|
| 858 |
-
if os.path.exists(SQLITE_DB):
|
| 859 |
-
print(f"Database file exists, size: {os.path.getsize(SQLITE_DB)} bytes")
|
| 860 |
-
else:
|
| 861 |
-
print("Warning: Database file does not exist after initialization!")
|
| 862 |
-
|
| 863 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 1 |
from flask import Flask, render_template, request, jsonify
|
| 2 |
+
import os, re, json
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
| 6 |
# ββββββββββββββββββββββββββ 1. CONFIGURATION ββββββββββββββββββββββββββ
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Domains that commonly block iframes
|
| 9 |
BLOCKED_DOMAINS = [
|
|
|
|
| 12 |
"ycombinator.com"
|
| 13 |
]
|
| 14 |
|
|
|
|
| 15 |
# ββββββββββββββββββββββββββ 2. CURATED CATEGORIES ββββββββββββββββββββββββββ
|
| 16 |
CATEGORIES = {
|
| 17 |
+
"Popular": [
|
| 18 |
+
"https://huggingface.co/spaces/openfree/AGI-Screenplay",
|
| 19 |
+
"https://huggingface.co/spaces/openfree/AGI-WebNovel",
|
| 20 |
+
"https://huggingface.co/spaces/openfree/AGI-NOVEL",
|
| 21 |
+
"https://huggingface.co/spaces/fantaxy/AGI-LEADERBOARD",
|
| 22 |
+
"https://cutechicken-3d-airforce-simulator.static.hf.space",
|
| 23 |
+
"https://huggingface.co/spaces/ginipick/Private-AI",
|
| 24 |
+
"https://huggingface.co/spaces/fantaxy/ofai-flx-logo",
|
| 25 |
+
"https://huggingface.co/spaces/aiqtech/FLUX-Ghibli-Studio-LoRA",
|
| 26 |
+
"https://huggingface.co/spaces/seawolf2357/REALVISXL-V5",
|
| 27 |
+
"https://huggingface.co/spaces/fantos/flx8lora",
|
| 28 |
+
"https://huggingface.co/spaces/ginipick/Realtime-FLUX",
|
| 29 |
+
"https://huggingface.co/spaces/fantaxy/flx-pulid",
|
| 30 |
+
"https://huggingface.co/spaces/ginipick/FLUX-Prompt-Generator",
|
| 31 |
+
"https://huggingface.co/spaces/aiqtech/kofaceid",
|
| 32 |
+
"https://huggingface.co/spaces/aiqtech/flxgif",
|
| 33 |
+
"https://huggingface.co/spaces/fantos/flxfashmodel",
|
| 34 |
+
"https://huggingface.co/spaces/fantos/flxcontrol",
|
| 35 |
+
"https://huggingface.co/spaces/fantos/textcutobject",
|
| 36 |
+
"https://huggingface.co/spaces/seawolf2357/flxloraexp",
|
| 37 |
+
"https://huggingface.co/spaces/fantaxy/flxloraexp",
|
| 38 |
+
"https://huggingface.co/spaces/aiqtech/imaginpaint",
|
| 39 |
+
"https://huggingface.co/spaces/ginipick/FLUXllama",
|
| 40 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored",
|
| 41 |
+
"https://huggingface.co/spaces/fantaxy/flx-upscale",
|
| 42 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video",
|
| 43 |
+
"https://huggingface.co/spaces/fantos/VoiceClone",
|
| 44 |
+
"https://huggingface.co/spaces/fantaxy/Rolls-Royce",
|
| 45 |
+
"https://huggingface.co/spaces/aiqtech/FLUX-military",
|
| 46 |
+
"https://huggingface.co/spaces/fantaxy/FLUX-Animations",
|
| 47 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video2",
|
| 48 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo",
|
| 49 |
+
"https://huggingface.co/spaces/ginipick/Time-Stream",
|
| 50 |
+
"https://huggingface.co/spaces/seawolf2357/sd-prompt-gen",
|
| 51 |
+
"https://huggingface.co/spaces/openfree/MagicFace-V3",
|
| 52 |
+
"https://huggingface.co/spaces/Heartsync/adult",
|
| 53 |
+
"https://huggingface.co/spaces/Heartsync/wan2-1-fast-security",
|
| 54 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-REAL",
|
| 55 |
+
"https://huggingface.co/spaces/seawolf2357/img2vid",
|
| 56 |
+
"https://huggingface.co/spaces/openfree/image-to-vector",
|
| 57 |
+
"https://huggingface.co/spaces/openfree/DreamO-video",
|
| 58 |
+
"https://huggingface.co/spaces/VIDraft/FramePack_rotate_landscape",
|
| 59 |
+
"https://huggingface.co/spaces/fantaxy/Sound-AI-SFX",
|
| 60 |
+
"https://huggingface.co/spaces/ginigen/VoiceClone-TTS",
|
| 61 |
+
"https://huggingface.co/spaces/Heartsync/FREE-NSFW-HUB",
|
| 62 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-image",
|
| 63 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-detection",
|
| 64 |
+
"https://huggingface.co/spaces/Heartsync/VEO3-RealTime",
|
| 65 |
+
"https://huggingface.co/spaces/ginigen/VEO3-Free",
|
| 66 |
+
"https://huggingface.co/spaces/ginigen/FLUX-Text-Tree-Image",
|
| 67 |
+
"https://huggingface.co/spaces/ginigen/text3d-r1",
|
| 68 |
+
"https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX",
|
| 69 |
+
|
| 70 |
+
],
|
| 71 |
+
"BEST": [
|
| 72 |
+
"https://huggingface.co/spaces/MaziyarPanahi/FACTS-Leaderboard",
|
| 73 |
+
"https://huggingface.co/spaces/ginigen/Flux-Kontext-Style",
|
| 74 |
+
"https://huggingface.co/spaces/openfree/Cycle-Navigator",
|
| 75 |
+
"https://huggingface.co/spaces/ginigen/Flux-Kontext-FaceLORA",
|
| 76 |
+
"https://huggingface.co/spaces/ginigen/Seedance-Free",
|
| 77 |
+
"https://huggingface.co/spaces/VIDraft/SOMA-AGI",
|
| 78 |
+
"https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard",
|
| 79 |
+
"https://huggingface.co/spaces/VIDraft/DNA-CASINO",
|
| 80 |
+
"https://huggingface.co/spaces/aiqtech/SOMA-Oriental",
|
| 81 |
+
"https://huggingface.co/spaces/fantaxy/YTB-TEST",
|
| 82 |
+
"https://huggingface.co/spaces/aiqtech/Contributors-Leaderboard",
|
| 83 |
+
"https://huggingface.co/spaces/ginigen/text3d-r1",
|
| 84 |
+
"https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX",
|
| 85 |
+
"https://huggingface.co/spaces/openfree/Korean-Leaderboard",
|
| 86 |
+
"https://huggingface.co/spaces/fantos/flxcontrol",
|
| 87 |
+
"https://huggingface.co/spaces/aiqtech/FLUX-Ghibli-Studio-LoRA",
|
| 88 |
+
"https://huggingface.co/spaces/openfree/AI-Podcast",
|
| 89 |
+
"https://huggingface.co/spaces/ginigen/Workflow-Canvas",
|
| 90 |
+
"https://huggingface.co/spaces/ginigen/3D-LLAMA",
|
| 91 |
+
"https://huggingface.co/spaces/ginigen/VoiceClone-TTS",
|
| 92 |
+
"https://huggingface.co/spaces/VIDraft/ACE-Singer",
|
| 93 |
+
"https://huggingface.co/spaces/ginipick/AI-BOOK",
|
| 94 |
+
"https://huggingface.co/spaces/immunobiotech/drug-discovery",
|
| 95 |
+
"https://huggingface.co/spaces/VIDraft/Robo-Beam",
|
| 96 |
+
"https://huggingface.co/spaces/fantaxy/fantasy-novel",
|
| 97 |
+
"https://huggingface.co/spaces/immunobiotech/Gemini-MICHELIN",
|
| 98 |
+
"https://huggingface.co/spaces/openfree/Chart-GPT",
|
| 99 |
+
"https://huggingface.co/spaces/ginipick/NH-Korea",
|
| 100 |
+
"https://huggingface.co/spaces/VIDraft/Voice-Clone-Podcast",
|
| 101 |
+
"https://huggingface.co/spaces/ginipick/Private-AI",
|
| 102 |
+
"https://huggingface.co/spaces/ginigen/Flux-VIDEO",
|
| 103 |
+
"https://huggingface.co/spaces/openfree/open-GAMMA",
|
| 104 |
+
"https://huggingface.co/spaces/ginipick/PharmAI-Korea",
|
| 105 |
+
"https://huggingface.co/spaces/ginipick/Pharmacy",
|
| 106 |
+
"https://huggingface.co/spaces/ginipick/PDF-EXAM",
|
| 107 |
+
"https://huggingface.co/spaces/ginipick/IDEA-DESIGN",
|
| 108 |
+
"https://huggingface.co/spaces/openfree/DreamO-video",
|
| 109 |
+
"https://huggingface.co/spaces/ginipick/10m-marketing",
|
| 110 |
+
"https://huggingface.co/spaces/VIDraft/voice-trans",
|
| 111 |
+
"https://huggingface.co/spaces/VIDraft/NH-Prediction",
|
| 112 |
+
"https://huggingface.co/spaces/fantos/flx8lora",
|
| 113 |
+
"https://huggingface.co/spaces/ginigen/MagicFace-V3",
|
| 114 |
+
"https://huggingface.co/spaces/openfree/Live-Podcast",
|
| 115 |
+
"https://huggingface.co/spaces/seawolf2357/ocrlatex",
|
| 116 |
+
"https://huggingface.co/spaces/Heartsync/VEO3-RealTime",
|
| 117 |
+
"https://huggingface.co/spaces/ginigen/VEO3-Free",
|
| 118 |
+
"https://huggingface.co/spaces/openfree/MagicFace-V3",
|
| 119 |
+
"https://huggingface.co/spaces/aiqtech/FLUX-military",
|
| 120 |
+
"https://huggingface.co/spaces/fantaxy/flxloraexp",
|
| 121 |
+
"https://huggingface.co/spaces/Heartsync/WAN2-1-fast-T2V-FusioniX",
|
| 122 |
+
"https://huggingface.co/spaces/ginigen/FLUXllama-Multilingual",
|
| 123 |
+
"https://huggingface.co/spaces/Heartsync/wan2-1-fast-security",
|
| 124 |
+
"https://huggingface.co/spaces/fantaxy/Rolls-Royce",
|
| 125 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-REAL",
|
| 126 |
+
"https://huggingface.co/spaces/ginipick/Realtime-FLUX",
|
| 127 |
+
"https://huggingface.co/spaces/aiqtech/imaginpaint",
|
| 128 |
+
"https://huggingface.co/spaces/aiqtech/flxgif",
|
| 129 |
+
"https://huggingface.co/spaces/fantos/flxfashmodel",
|
| 130 |
+
"https://huggingface.co/spaces/aiqtech/kofaceid",
|
| 131 |
+
"https://huggingface.co/spaces/ginipick/FLUX-Prompt-Generator",
|
| 132 |
+
"https://huggingface.co/spaces/seawolf2357/REALVISXL-V5",
|
| 133 |
+
"https://huggingface.co/spaces/fantaxy/FLUX-Animations",
|
| 134 |
+
"https://huggingface.co/spaces/fantaxy/flx-pulid",
|
| 135 |
+
"https://huggingface.co/spaces/fantaxy/ofai-flx-logo",
|
| 136 |
+
"https://huggingface.co/spaces/openfree/image-to-vector",
|
| 137 |
+
"https://huggingface.co/spaces/Heartsync/FREE-NSFW-HUB",
|
| 138 |
+
"https://huggingface.co/spaces/seawolf2357/sd-prompt-gen",
|
| 139 |
+
"https://huggingface.co/spaces/VIDraft/FramePack_rotate_landscape",
|
| 140 |
+
"https://huggingface.co/spaces/ginipick/FLUXllama",
|
| 141 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-image",
|
| 142 |
+
"https://huggingface.co/spaces/seawolf2357/img2vid",
|
| 143 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video2",
|
| 144 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-detection",
|
| 145 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video",
|
| 146 |
+
"https://huggingface.co/spaces/Heartsync/adult",
|
| 147 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored",
|
| 148 |
+
"https://huggingface.co/spaces/fantos/VoiceClone",
|
| 149 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo",
|
| 150 |
+
"https://huggingface.co/spaces/fantaxy/flx-upscale",
|
| 151 |
+
"https://huggingface.co/spaces/seawolf2357/flxloraexp",
|
| 152 |
+
"https://huggingface.co/spaces/ginipick/Time-Stream",
|
| 153 |
+
"https://huggingface.co/spaces/fantos/textcutobject",
|
| 154 |
|
| 155 |
+
|
| 156 |
+
],
|
| 157 |
+
"NEW": [
|
| 158 |
+
"https://huggingface.co/spaces/ginigen/Flux-Kontext-Style",
|
| 159 |
+
"https://cutechicken-3d-airforce-simulator.static.hf.space",
|
| 160 |
+
"https://huggingface.co/spaces/ginipick/Private-AI",
|
| 161 |
+
"https://huggingface.co/spaces/VIDraft/ACE-Singer",
|
| 162 |
+
"https://huggingface.co/spaces/ginipick/AI-BOOK",
|
| 163 |
+
"https://huggingface.co/spaces/openfree/Best-AI",
|
| 164 |
"https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard",
|
| 165 |
"https://huggingface.co/spaces/VIDraft/DNA-CASINO",
|
| 166 |
+
"https://huggingface.co/spaces/openfree/AGI-Screenplay",
|
| 167 |
+
"https://huggingface.co/spaces/openfree/AGI-WebNovel",
|
| 168 |
+
"https://huggingface.co/spaces/openfree/AGI-NOVEL",
|
| 169 |
+
"https://huggingface.co/spaces/fantaxy/AGI-LEADERBOARD",
|
| 170 |
+
"https://huggingface.co/spaces/ginigen/Seedance-Free",
|
| 171 |
+
"https://huggingface.co/spaces/aiqtech/SOMA-Oriental",
|
| 172 |
+
"https://huggingface.co/spaces/ginigen/Flux-Kontext-FaceLORA",
|
| 173 |
+
"https://huggingface.co/spaces/VIDraft/SOMA-AGI",
|
| 174 |
+
"https://huggingface.co/spaces/Heartsync/VEO3-RealTime",
|
| 175 |
+
"https://huggingface.co/spaces/openfree/Open-GAMMA",
|
| 176 |
+
"https://huggingface.co/spaces/ginigen/VEO3-Free",
|
| 177 |
+
"https://huggingface.co/spaces/Heartsync/WAN2-1-fast-T2V-FusioniX",
|
| 178 |
+
"https://huggingface.co/spaces/VIDraft/voice-trans",
|
| 179 |
+
"https://huggingface.co/spaces/VIDraft/Robo-Beam",
|
| 180 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-REAL",
|
| 181 |
+
"https://huggingface.co/spaces/fantaxy/fantasy-novel",
|
| 182 |
+
"https://huggingface.co/spaces/openfree/Chart-GPT",
|
| 183 |
+
"https://huggingface.co/spaces/Heartsync/Novel-NSFW",
|
| 184 |
+
"https://huggingface.co/spaces/ginigen/FLUX-Ghibli-LoRA2",
|
| 185 |
+
"https://huggingface.co/spaces/Heartsync/WAN-VIDEO-AUDIO",
|
| 186 |
+
"https://huggingface.co/spaces/Heartsync/wan2-1-fast-security",
|
| 187 |
+
"https://huggingface.co/spaces/ginigen/Flux-VIDEO",
|
| 188 |
+
"https://huggingface.co/spaces/aiqcamp/REMOVAL-TEXT-IMAGE",
|
| 189 |
+
"https://huggingface.co/spaces/VIDraft/Mistral-RAG-BitSix",
|
| 190 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video2",
|
| 191 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video",
|
| 192 |
+
"https://huggingface.co/spaces/fantaxy/YTB-TEST",
|
| 193 |
+
"https://huggingface.co/spaces/Heartsync/FREE-NSFW-HUB",
|
| 194 |
+
"https://huggingface.co/spaces/Heartsync/adult",
|
| 195 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo",
|
| 196 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored",
|
| 197 |
+
"https://huggingface.co/spaces/openfree/Live-Podcast",
|
| 198 |
+
"https://huggingface.co/spaces/openfree/AI-Podcast",
|
| 199 |
+
"https://huggingface.co/spaces/ginipick/NH-Korea",
|
| 200 |
+
"https://huggingface.co/spaces/VIDraft/NH-Prediction",
|
| 201 |
+
"https://huggingface.co/spaces/VIDraft/Voice-Clone-Podcast",
|
| 202 |
+
"https://huggingface.co/spaces/ginipick/PDF-EXAM",
|
| 203 |
+
"https://huggingface.co/spaces/openfree/Game-Gallery",
|
| 204 |
+
"https://huggingface.co/spaces/openfree/Vibe-Game",
|
| 205 |
+
"https://huggingface.co/spaces/ginipick/IDEA-DESIGN",
|
| 206 |
+
"https://huggingface.co/spaces/openfree/Cycle-Navigator",
|
| 207 |
+
"https://huggingface.co/spaces/openfree/DreamO-video",
|
| 208 |
+
"https://huggingface.co/spaces/Heartsync/NSFW-detection",
|
| 209 |
+
|
| 210 |
|
| 211 |
+
],
|
| 212 |
+
"Productivity": [
|
| 213 |
+
"https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard",
|
| 214 |
+
"https://huggingface.co/spaces/VIDraft/DNA-CASINO",
|
| 215 |
"https://huggingface.co/spaces/openfree/Open-GAMMA",
|
| 216 |
"https://huggingface.co/spaces/VIDraft/Robo-Beam",
|
| 217 |
"https://huggingface.co/spaces/VIDraft/voice-trans",
|
|
|
|
| 223 |
"https://huggingface.co/spaces/ginigen/perflexity-clone",
|
| 224 |
"https://huggingface.co/spaces/ginipick/IDEA-DESIGN",
|
| 225 |
"https://huggingface.co/spaces/ginipick/10m-marketing",
|
|
|
|
| 226 |
"https://huggingface.co/spaces/openfree/Live-Podcast",
|
| 227 |
"https://huggingface.co/spaces/openfree/AI-Podcast",
|
| 228 |
"https://huggingface.co/spaces/ginipick/QR-Canvas-plus",
|
|
|
|
| 235 |
"https://huggingface.co/spaces/ginipick/Change-Hair",
|
| 236 |
],
|
| 237 |
"Multimodal": [
|
|
|
|
| 238 |
"https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo",
|
|
|
|
| 239 |
"https://huggingface.co/spaces/fantaxy/YTB-TEST",
|
| 240 |
"https://huggingface.co/spaces/ginigen/Seedance-Free",
|
| 241 |
"https://huggingface.co/spaces/Heartsync/VEO3-RealTime",
|
|
|
|
| 307 |
"https://huggingface.co/spaces/openfree/VectorFlow",
|
| 308 |
"https://huggingface.co/spaces/ginigen/3D-LLAMA",
|
| 309 |
"https://huggingface.co/spaces/ginigen/Multi-LoRAgen",
|
|
|
|
| 310 |
],
|
| 311 |
"LLM / VLM": [
|
| 312 |
"https://huggingface.co/spaces/fantaxy/fantasy-novel",
|
|
|
|
| 327 |
],
|
| 328 |
}
|
| 329 |
|
| 330 |
+
# ββββββββββββββββββββββββββ 3. URL HELPERS ββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
def direct_url(hf_url):
|
| 332 |
m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", hf_url)
|
| 333 |
if not m:
|
|
|
|
| 365 |
# Default handling
|
| 366 |
return url, "iframe"
|
| 367 |
|
| 368 |
+
# ββββββββββββββββββββββββββ 4. API ROUTES ββββββββββββββββββββββββββ
|
| 369 |
@app.route('/api/category')
|
| 370 |
def api_category():
|
| 371 |
cat = request.args.get('name', '')
|
| 372 |
urls = CATEGORIES.get(cat, [])
|
| 373 |
|
| 374 |
+
# Add pagination for categories
|
| 375 |
page = int(request.args.get('page', 1))
|
| 376 |
+
per_page = int(request.args.get('per_page', 4))
|
| 377 |
|
| 378 |
total_pages = max(1, (len(urls) + per_page - 1) // per_page)
|
| 379 |
start = (page - 1) * per_page
|
|
|
|
| 397 |
"total_pages": total_pages
|
| 398 |
})
|
| 399 |
|
| 400 |
+
# ββββββββββββββββββββββββββ 5. MAIN ROUTES ββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
@app.route('/')
|
| 402 |
def home():
|
| 403 |
os.makedirs('templates', exist_ok=True)
|
|
|
|
| 415 |
.tabs{display:flex;flex-wrap:wrap;gap:8px;padding:16px;}
|
| 416 |
.tab{padding:6px 14px;border:none;border-radius:18px;background:#e2e8f0;font-weight:600;cursor:pointer;}
|
| 417 |
.tab.active{background:#a78bfa;color:#1a202c;}
|
| 418 |
+
.tab.popular{background:#ff6b6b;color:white;}
|
| 419 |
+
.tab.popular.active{background:#fa5252;color:white;}
|
| 420 |
+
.tab.best{background:#4ecdc4;color:white;}
|
| 421 |
+
.tab.best.active{background:#38d9a9;color:white;}
|
| 422 |
+
.tab.new{background:#ffe066;color:#1a202c;}
|
| 423 |
+
.tab.new.active{background:#ffd43b;color:#1a202c;}
|
| 424 |
/* Updated grid to show 2x2 layout */
|
| 425 |
.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:20px;padding:0 16px 60px;max-width:1200px;margin:0 auto;}
|
| 426 |
@media(max-width:800px){.grid{grid-template-columns:1fr;}}
|
|
|
|
| 437 |
.pagination{display:flex;justify-content:center;margin:20px 0;gap:10px;}
|
| 438 |
.pagination button{padding:5px 15px;border:none;border-radius:20px;background:#e2e8f0;cursor:pointer;}
|
| 439 |
.pagination button:disabled{opacity:0.5;cursor:not-allowed;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
</style>
|
| 441 |
</head>
|
| 442 |
<body>
|
| 443 |
<header style="text-align: center; padding: 20px; background: linear-gradient(135deg, #f6f8fb, #e2e8f0); border-bottom: 1px solid #ddd;">
|
| 444 |
+
<h1 style="margin-bottom: 10px;">πOPEN & Free: BEST AI Playground</h1>
|
| 445 |
<p>
|
| 446 |
+
<a href="https://huggingface.co/OpenFreeAI" target="_blank"><img src="https://img.shields.io/static/v1?label=Community&message=OpenFree_AI&color=%23800080&labelColor=%23000080&logo=HUGGINGFACE&logoColor=%23ffa500&style=for-the-badge" alt="badge"></a>
|
| 447 |
<a href="https://discord.gg/openfreeai" target="_blank"><img src="https://img.shields.io/static/v1?label=Discord&message=Openfree%20AI&color=%230000ff&labelColor=%23800080&logo=discord&logoColor=white&style=for-the-badge" alt="badge"></a>
|
| 448 |
+
<a href="https://huggingface.co/spaces/openfree/Best-AI" target="_blank"><img src="https://img.shields.io/static/v1?label=OpenFree&message=BEST%20AI%20Services&color=%230000ff&labelColor=%23000080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="badge"></a>
|
| 449 |
+
</p>
|
| 450 |
</header>
|
| 451 |
<div class="tabs" id="tabs"></div>
|
| 452 |
<div id="content"></div>
|
|
|
|
| 460 |
let currentPage = 1;
|
| 461 |
|
| 462 |
// Simple utility functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
function makeRequest(url, method, data, callback) {
|
| 464 |
const xhr = new XMLHttpRequest();
|
| 465 |
xhr.open(method, url, true);
|
|
|
|
| 526 |
});
|
| 527 |
}
|
| 528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
// Create tabs
|
| 530 |
+
// Special tabs first (Popular, BEST, NEW)
|
| 531 |
+
['Popular', 'BEST', 'NEW'].forEach(specialCat => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
const b = document.createElement('button');
|
| 533 |
+
b.className = 'tab ' + specialCat.toLowerCase();
|
| 534 |
+
b.textContent = specialCat;
|
| 535 |
+
b.dataset.c = specialCat;
|
| 536 |
+
b.onclick = function() { loadCategory(specialCat, 1); };
|
| 537 |
tabs.appendChild(b);
|
| 538 |
});
|
| 539 |
|
| 540 |
+
// Regular category tabs
|
| 541 |
+
cats.forEach(c => {
|
| 542 |
+
if (!['Popular', 'BEST', 'NEW'].includes(c)) {
|
| 543 |
+
const b = document.createElement('button');
|
| 544 |
+
b.className = 'tab';
|
| 545 |
+
b.textContent = c;
|
| 546 |
+
b.dataset.c = c;
|
| 547 |
+
b.onclick = function() { loadCategory(c, 1); };
|
| 548 |
+
tabs.appendChild(b);
|
| 549 |
+
}
|
| 550 |
+
});
|
| 551 |
|
| 552 |
+
// Start with Popular tab
|
| 553 |
+
loadCategory('Popular', 1);
|
| 554 |
</script>
|
| 555 |
</body>
|
| 556 |
</html>''')
|
|
|
|
| 558 |
# Return the rendered template
|
| 559 |
return render_template('index.html', cats=list(CATEGORIES.keys()))
|
| 560 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
app.run(host='0.0.0.0', port=7860)
|