File size: 13,883 Bytes
5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 dd72aae 5af9b43 b0a8d32 5af9b43 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
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'''<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Free NSFW Hub</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;600&display=swap');
body{margin:0;font-family:Nunito,sans-serif;background:#f6f8fb;}
.tabs{display:flex;flex-wrap:wrap;gap:8px;padding:16px;}
.tab{padding:6px 14px;border:none;border-radius:18px;background:#e2e8f0;font-weight:600;cursor:pointer;}
.tab.active{background:#a78bfa;color:#1a202c;}
/* Updated grid to show 2x2 layout */
.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:20px;padding:0 16px 60px;max-width:1200px;margin:0 auto;}
@media(max-width:800px){.grid{grid-template-columns:1fr;}}
/* Increased card height for larger display */
.card{background:#fff;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,.08);overflow:hidden;height:540px;display:flex;flex-direction:column;position:relative;}
.frame{flex:1;position:relative;overflow:hidden;}
.frame iframe{position:absolute;width:166.667%;height:166.667%;transform:scale(.6);transform-origin:top left;border:0;}
.frame img{width:100%;height:100%;object-fit:cover;}
.card-label{position:absolute;top:10px;left:10px;padding:4px 8px;border-radius:4px;font-size:11px;font-weight:bold;z-index:100;text-transform:uppercase;letter-spacing:0.5px;box-shadow:0 2px 4px rgba(0,0,0,0.2);}
.label-live{background:linear-gradient(135deg, #00c6ff, #0072ff);color:white;}
.label-static{background:linear-gradient(135deg, #ff9a9e, #fad0c4);color:#333;}
.foot{height:44px;background:#fafafa;display:flex;align-items:center;justify-content:center;border-top:1px solid #eee;}
.foot a{font-size:.82rem;font-weight:700;color:#4a6dd8;text-decoration:none;}
.pagination{display:flex;justify-content:center;margin:20px 0;gap:10px;}
.pagination button{padding:5px 15px;border:none;border-radius:20px;background:#e2e8f0;cursor:pointer;}
.pagination button:disabled{opacity:0.5;cursor:not-allowed;}
</style>
</head>
<body>
<header style="text-align: center; padding: 20px; background: linear-gradient(135deg, #f6f8fb, #e2e8f0); border-bottom: 1px solid #ddd;">
<h1 style="margin-bottom: 10px;">π₯Free NSFW Hub</h1>
<p style="margin-bottom: 15px; color: #666; font-size: 14px;">
A curated collection of the most popular and polished NSFW Detection projects on Hugging Face Spaces,<br>
organized for easy visual exploration and discovery.
</p>
<p>
<a href="https://huggingface.co/spaces/Heartsync/FREE-NSFW-HUB" target="_blank"><img src="https://img.shields.io/static/v1?label=huggingface&message=FREE%20NSFW%20HUB&color=%230000ff&labelColor=%23800080&logo=huggingface&logoColor=%23ffa500&style=for-the-badge" alt="badge"></a>
</p>
</header>
<div class="tabs" id="tabs"></div>
<div id="content"></div>
<script>
// Basic configuration
const cats = {{cats|tojson}};
const tabs = document.getElementById('tabs');
const content = document.getElementById('content');
let active = "";
let currentPage = 1;
// Simple utility functions
function makeRequest(url, method, data, callback) {
const xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
callback(JSON.parse(xhr.responseText));
}
};
if (method === 'POST') {
xhr.send(data);
} else {
xhr.send();
}
}
function updateTabs() {
Array.from(tabs.children).forEach(b => {
b.classList.toggle('active', b.dataset.c === active);
});
}
// Tab handler for categories
function loadCategory(cat, page) {
if(cat === active && currentPage === page) return;
active = cat;
currentPage = page || 1;
updateTabs();
content.innerHTML = '<p style="text-align:center;padding:40px">Loadingβ¦</p>';
makeRequest('/api/category?name=' + encodeURIComponent(cat) + '&page=' + currentPage + '&per_page=4', 'GET', null, function(data) {
let html = '<div class="grid">';
if(data.items.length === 0) {
html += '<p style="grid-column:1/-1;text-align:center;padding:40px">No items in this category.</p>';
} else {
data.items.forEach(item => {
html += `
<div class="card">
<div class="card-label label-live">LIVE</div>
<div class="frame">
<iframe src="${item.iframe}" loading="lazy" sandbox="allow-forms allow-modals allow-popups allow-same-origin allow-scripts allow-downloads"></iframe>
</div>
<div class="foot">
<a href="${item.hf}" target="_blank">${item.title}</a>
</div>
</div>
`;
});
}
html += '</div>';
// Add pagination
html += `
<div class="pagination">
<button ${currentPage <= 1 ? 'disabled' : ''} onclick="loadCategory('${cat}', ${currentPage-1})">Β« Previous</button>
<span>Page ${currentPage} of ${data.total_pages}</span>
<button ${currentPage >= data.total_pages ? 'disabled' : ''} onclick="loadCategory('${cat}', ${currentPage+1})">Next Β»</button>
</div>
`;
content.innerHTML = html;
});
}
// Create category tabs
cats.forEach(c => {
const b = document.createElement('button');
b.className = 'tab';
b.textContent = c;
b.dataset.c = c;
b.onclick = function() { loadCategory(c, 1); };
tabs.appendChild(b);
});
// Start with the first category (Productivity)
loadCategory(cats[0], 1);
</script>
</body>
</html>''')
# Return the rendered template
return render_template('index.html', cats=list(CATEGORIES.keys()))
if __name__ == '__main__':
app.run(host='0.0.0.0', port=7860) |