from flask import Flask, render_template, request, jsonify import os, re, json app = Flask(__name__) # ────────────────────────── 1. CURATED CATEGORIES ────────────────────────── CATEGORIES = { "Productivity": [ "https://huggingface.co/spaces/ginigen/perflexity-clone", "https://huggingface.co/spaces/ginipick/IDEA-DESIGN", "https://huggingface.co/spaces/VIDraft/mouse-webgen", "https://huggingface.co/spaces/openfree/Vibe-Game", "https://huggingface.co/spaces/openfree/Game-Gallery", "https://huggingface.co/spaces/aiqtech/Contributors-Leaderboard", "https://huggingface.co/spaces/fantaxy/Model-Leaderboard", "https://huggingface.co/spaces/fantaxy/Space-Leaderboard", "https://huggingface.co/spaces/openfree/Korean-Leaderboard", ], "Multimodal": [ "https://huggingface.co/spaces/openfree/DreamO-video", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored", "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX", "https://huggingface.co/spaces/ginigen/SFX-Sound-magic", "https://huggingface.co/spaces/ginigen/VoiceClone-TTS", "https://huggingface.co/spaces/aiqcamp/MCP-kokoro", "https://huggingface.co/spaces/aiqcamp/ENGLISH-Speaking-Scoring", ], "Professional": [ "https://huggingface.co/spaces/ginigen/blogger", "https://huggingface.co/spaces/VIDraft/money-radar", "https://huggingface.co/spaces/immunobiotech/drug-discovery", "https://huggingface.co/spaces/immunobiotech/Gemini-MICHELIN", "https://huggingface.co/spaces/Heartsync/Papers-Leaderboard", "https://huggingface.co/spaces/VIDraft/PapersImpact", "https://huggingface.co/spaces/ginipick/AgentX-Papers", "https://huggingface.co/spaces/openfree/Cycle-Navigator", ], "Image": [ "https://huggingface.co/spaces/ginigen/interior-design", "https://huggingface.co/spaces/ginigen/Workflow-Canvas", "https://huggingface.co/spaces/ginigen/Multi-LoRAgen", "https://huggingface.co/spaces/ginigen/Every-Text", "https://huggingface.co/spaces/ginigen/text3d-r1", "https://huggingface.co/spaces/ginipick/FLUXllama", "https://huggingface.co/spaces/Heartsync/FLUX-Vision", "https://huggingface.co/spaces/ginigen/VisualCloze", "https://huggingface.co/spaces/seawolf2357/Ghibli-Multilingual-Text-rendering", "https://huggingface.co/spaces/ginigen/Ghibli-Meme-Studio", "https://huggingface.co/spaces/VIDraft/Open-Meme-Studio", "https://huggingface.co/spaces/ginigen/3D-LLAMA", ], "LLM / VLM": [ "https://huggingface.co/spaces/VIDraft/Gemma-3-R1984-4B", "https://huggingface.co/spaces/VIDraft/Gemma-3-R1984-12B", "https://huggingface.co/spaces/ginigen/Mistral-Perflexity", "https://huggingface.co/spaces/aiqcamp/gemini-2.5-flash-preview", "https://huggingface.co/spaces/openfree/qwen3-30b-a3b-research", "https://huggingface.co/spaces/openfree/qwen3-235b-a22b-research", "https://huggingface.co/spaces/openfree/Llama-4-Maverick-17B-Research", ], } # ─────────────── 2. URL HELPERS ──────────────── def direct_url(hf_url: str) -> str: m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", hf_url) if not m: return hf_url owner, name = m.groups() owner = owner.lower() name = name.replace('.', '-').replace('_', '-').lower() return f"https://{owner}-{name}.hf.space" def screenshot_url(hf_url: str) -> str: return f"https://image.thum.io/get/fullpage/{direct_url(hf_url)}" # ─────────────── 3. API FOR TABS ─────────────── @app.route('/api/category') def api_category(): cat = request.args.get('name', '') urls = CATEGORIES.get(cat, []) return jsonify([ { "title": url.split('/')[-1], "owner": url.split('/')[-2] if '/spaces/' in url else '', "iframe": direct_url(url), "shot": screenshot_url(url), "hf": url } for url in urls ]) # ─────────────── 4. ROUTES ─────────────── @app.route('/') def home(): return render_template('index.html', cats=list(CATEGORIES.keys())) # ─────────────── 5. CREATE TEMPLATE ─────────────── os.makedirs('templates', exist_ok=True) with open('templates/index.html', 'w', encoding='utf-8') as fp: fp.write(r'''