from flask import Flask, render_template, request, jsonify import os, re, json app = Flask(__name__) # ────────────────────────── 1. CONFIGURATION ────────────────────────── # Domains that commonly block iframes BLOCKED_DOMAINS = [ "naver.com", "daum.net", "google.com", "facebook.com", "instagram.com", "kakao.com", "ycombinator.com" ] # ────────────────────────── 2. CURATED CATEGORIES ────────────────────────── CATEGORIES = { "Popular": [ "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-REAL", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored", "https://huggingface.co/spaces/Dagfinn1962/Midjourney-Free", #### "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video2", "https://huggingface.co/spaces/Heartsync/Novel-NSFW", "https://huggingface.co/spaces/erax/EraX-NSFW-V1.0", ### "https://huggingface.co/spaces/yoinked/da_nsfw_checker", ##### "https://huggingface.co/spaces/LearningnRunning/adult_image_detector", ### ], "BEST": [ "https://huggingface.co/spaces/Heartsync/adult", "https://huggingface.co/spaces/ginigen/Flux-VIDEO", "https://huggingface.co/spaces/openfree/DreamO-video", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video", "https://huggingface.co/spaces/Heartsync/NSFW-novels", "https://huggingface.co/spaces/fantaxy/fantasy-novel", ], "TEXT generate": [ "https://huggingface.co/spaces/Heartsync/Novel-NSFW", "https://huggingface.co/spaces/fantaxy/fantasy-novel", "https://huggingface.co/spaces/Heartsync/NSFW-novels", ], "TEXT TO IMAGE": [ "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-photo", "https://huggingface.co/spaces/Heartsync/adult", "https://huggingface.co/spaces/Heartsync/NSFW-novels", "https://huggingface.co/spaces/IbarakiDouji/WAI-NSFW-illustrious-SDXL", ### "https://huggingface.co/spaces/armen425221356/UnfilteredAI-NSFW-gen-v2_self_parms", #### ], "IMAGE TO VIDEO": [ "https://huggingface.co/spaces/Heartsync/adult", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video", "https://huggingface.co/spaces/Heartsync/NSFW-Uncensored-video2", "https://huggingface.co/spaces/openfree/DreamO-video", "https://huggingface.co/spaces/Heartsync/wan2-1-fast-security", "https://huggingface.co/spaces/ginigen/Flux-VIDEO", "https://huggingface.co/spaces/Heartsync/WAN-VIDEO-AUDIO", ], "IMAGE IN/OUT-PAINTING": [ "https://huggingface.co/spaces/ginigen/FLUX-Ghibli-LoRA2", "https://huggingface.co/spaces/davecarrau/nsfw-face-swap", ### "https://huggingface.co/spaces/VIDraft/ReSize-Image-Outpainting", "https://huggingface.co/spaces/aiqcamp/REMOVAL-TEXT-IMAGE", "https://huggingface.co/spaces/ginigen/MagicFace-V3", "https://huggingface.co/spaces/openfree/ColorRevive", "https://huggingface.co/spaces/ginigen/VisualCloze", "https://huggingface.co/spaces/fantos/textcutobject", ], "Extension": [ "https://huggingface.co/spaces/erax/EraX-NSFW-V1.0", ### "https://huggingface.co/spaces/yoinked/da_nsfw_checker", ##### "https://huggingface.co/spaces/LearningnRunning/adult_image_detector", ### "https://huggingface.co/spaces/VIDraft/ACE-Singer", "https://huggingface.co/spaces/VIDraft/Voice-Clone-Podcast", "https://huggingface.co/spaces/ginigen/VoiceClone-TTS", "https://huggingface.co/spaces/openfree/Multilingual-TTS", "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX", "https://huggingface.co/spaces/ginigen/SFX-Sound-magic", "https://huggingface.co/spaces/fantaxy/Remove-Video-Background", "https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX", "https://huggingface.co/spaces/aiqtech/imaginpaint", "https://huggingface.co/spaces/openfree/ultpixgen", # "https://huggingface.co/spaces/ginipick/Change-Hair", # "https://huggingface.co/spaces/ginigen/Every-Text", ], "Utility": [ "https://huggingface.co/spaces/openfree/Chart-GPT", "https://huggingface.co/spaces/ginipick/AI-BOOK", "https://huggingface.co/spaces/openfree/Live-Podcast", "https://huggingface.co/spaces/openfree/AI-Podcast", "https://huggingface.co/spaces/ginipick/FLUXllama", "https://huggingface.co/spaces/VIDraft/Polaroid-Style", "https://huggingface.co/spaces/ginigen/text3d-r1", "https://huggingface.co/spaces/openfree/Naming", "https://huggingface.co/spaces/ginigen/3D-LLAMA-V1", "https://huggingface.co/spaces/fantaxy/flx-pulid", ], } # ────────────────────────── 3. URL HELPERS ────────────────────────── def direct_url(hf_url): 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(url): return f"https://image.thum.io/get/fullpage/{url}" def process_url_for_preview(url): """Returns (preview_url, mode)""" # Handle blocked domains first if any(d for d in BLOCKED_DOMAINS if d in url): return screenshot_url(url), "snapshot" # Special case handling for problematic URLs if "vibe-coding-tetris" in url or "World-of-Tank-GAME" in url or "Minesweeper-Game" in url: return screenshot_url(url), "snapshot" # General HF space handling try: if "huggingface.co/spaces" in url: parts = url.rstrip("/").split("/") if len(parts) >= 5: owner = parts[-2] name = parts[-1] embed_url = f"https://huggingface.co/spaces/{owner}/{name}/embed" return embed_url, "iframe" except Exception: return screenshot_url(url), "snapshot" # Default handling return url, "iframe" # ────────────────────────── 4. API ROUTES ────────────────────────── @app.route('/api/category') def api_category(): cat = request.args.get('name', '') urls = CATEGORIES.get(cat, []) # Add pagination for categories page = int(request.args.get('page', 1)) per_page = int(request.args.get('per_page', 4)) # 4 per page for 2x2 grid total_pages = max(1, (len(urls) + per_page - 1) // per_page) start = (page - 1) * per_page end = min(start + per_page, len(urls)) urls_page = urls[start:end] items = [ { "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_page ] return jsonify({ "items": items, "page": page, "total_pages": total_pages }) # ────────────────────────── 5. MAIN ROUTES ────────────────────────── @app.route('/') def home(): os.makedirs('templates', exist_ok=True) with open('templates/index.html', 'w', encoding='utf-8') as fp: fp.write(r'''
A curated collection of the most popular and polished NSFW Detection projects on Hugging Face Spaces,
organized for easy visual exploration and discovery.