from flask import Flask, render_template, request, jsonify import os, re, json app = Flask(__name__) # 1️⃣ curated lists ---------------------------------------------------------- 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 to_direct(url: str) -> str: m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", url) if not m: return url owner, space = m.groups() owner = owner.lower() space = space.replace('.', '-').replace('_', '-').lower() return f"https://{owner}-{space}.hf.space" def to_snapshot(url: str) -> str: return f"https://image.thum.io/get/fullpage/{to_direct(url)}" # 3️⃣ simple API ----------------------------------------------------------- @app.route('/api/category') def api_cat(): name = request.args.get('name', '') urls = CATEGORIES.get(name, []) return jsonify([{ "title": url.split('/')[-1], "img": to_snapshot(url), "link": to_direct(url) } for url in urls]) # 4️⃣ web front ------------------------------------------------------------ @app.route('/') def home(): return render_template('index.html', cats=list(CATEGORIES.keys())) # 5️⃣ generate template once ---------------------------------------------- os.makedirs('templates', exist_ok=True) with open('templates/index.html', 'w', encoding='utf-8') as fp: fp.write(r'''