Spaces:
Sleeping
Sleeping
Update app.py
Browse files12345678910112 unmodified lines14151617181920212223242526272 unmodified lines30313233343536373839404142434445464748495051525354555657585960616263641 unmodified line666768697071727374757677787980818283848586878889909192939495969798991001011023 unmodified lines106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271import gradio as grfrom flask import Flask, render_template_string, request, jsonifyimport re# โโโโโโโโโโโโโโโโโโโโโโโโโโ FLASK APP โโโโโโโโโโโโโโโโโโโโโโโโโโflask_app = Flask(__name__)# โโโโโโโโโโโโโโโโโโโโโโโโโโ CURATED CATEGORIES โโโโโโโโโโโโโโโโโโโโโโโโโโCATEGORIES = {"Popular": ["https://huggingface.co/spaces/fantos/Heatmap-Leaderboard-KOREA",2 unmodified lines"https://huggingface.co/spaces/ginigen/SAJU","https://huggingface.co/spaces/ginipick/SAJU-Couple","https://huggingface.co/spaces/openfree/News-AI","https://huggingface.co/spaces/openfree/Creative-Arena-Leaderboard","https://huggingface.co/spaces/openfree/Face-blurring","https://huggingface.co/spaces/ginigen/Fashion-Fit360","https://huggingface.co/spaces/VIDraft/DNA-Diffusion","https://huggingface.co/spaces/Heartsync/Nano-Banana","https://huggingface.co/spaces/openfree/AGI-Screenplay-Pro","https://huggingface.co/spaces/ginipick/FLUXllama","https://huggingface.co/spaces/VIDraft/gpt-oss-RAG","https://huggingface.co/spaces/ginigen/VEO3-Free","https://huggingface.co/spaces/ginigen/text3d-r1","https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX",2 unmodified lines"https://huggingface.co/spaces/ginipick/AGI-Personal","https://huggingface.co/spaces/ginigen/AI","https://huggingface.co/spaces/ginigen/AGI-WebToon-KOREA","https://huggingface.co/spaces/ginigen/webtoon-studio","https://huggingface.co/spaces/MaziyarPanahi/FACTS-Leaderboard","https://huggingface.co/spaces/ginigen/Flux-Kontext-Style","https://huggingface.co/spaces/openfree/Cycle-Navigator","https://huggingface.co/spaces/ginigen/Flux-Kontext-FaceLORA","https://huggingface.co/spaces/ginigen/Seedance-Free","https://huggingface.co/spaces/VIDraft/SOMA-AGI","https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard","https://huggingface.co/spaces/VIDraft/DNA-CASINO","https://huggingface.co/spaces/aiqtech/SOMA-Oriental",],"NEW": ["https://huggingface.co/spaces/ginigen/Family","https://huggingface.co/spaces/ginigen/AGI-Screenplay","https://huggingface.co/spaces/openfree/OpenAI-gpt-oss","https://huggingface.co/spaces/ginipick/Private-AI","https://huggingface.co/spaces/VIDraft/ACE-Singer","https://huggingface.co/spaces/ginipick/AI-BOOK","https://huggingface.co/spaces/openfree/Best-AI","https://huggingface.co/spaces/Heartsync/VEO3-RealTime","https://huggingface.co/spaces/openfree/Open-GAMMA",],"Productivity": ["https://huggingface.co/spaces/ginigen/Markets","https://huggingface.co/spaces/VIDraft/Robo-Beam","https://huggingface.co/spaces/VIDraft/voice-trans","https://huggingface.co/spaces/openfree/Chart-GPT","https://huggingface.co/spaces/VIDraft/Voice-Clone-Podcast","https://huggingface.co/spaces/ginipick/PDF-EXAM",],"Multimodal": ["https://huggingface.co/spaces/ginigen/Seedance-Free",1 unmodified line"https://huggingface.co/spaces/ginigen/VEO3-Free","https://huggingface.co/spaces/ginigen/Flux-VIDEO","https://huggingface.co/spaces/VIDraft/ACE-Singer","https://huggingface.co/spaces/openfree/DreamO-video","https://huggingface.co/spaces/ginigen/VoiceClone-TTS",],"Professional": ["https://huggingface.co/spaces/aiqtech/SOMA-Oriental","https://huggingface.co/spaces/VIDraft/SOMA-AGI","https://huggingface.co/spaces/VIDraft/money-radar","https://huggingface.co/spaces/immunobiotech/drug-discovery","https://huggingface.co/spaces/openfree/Cycle-Navigator","https://huggingface.co/spaces/VIDraft/Fashion-Fit",],"Image": ["https://huggingface.co/spaces/openfree/Face-blurring","https://huggingface.co/spaces/ginigen/Flux-Kontext-FaceLORA","https://huggingface.co/spaces/ginigen/text3d-r1","https://huggingface.co/spaces/ginipick/FLUXllama","https://huggingface.co/spaces/ginigen/Workflow-Canvas","https://huggingface.co/spaces/ginigen/MagicFace-V3","https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX","https://huggingface.co/spaces/ginigen/3D-LLAMA",],"LLM / VLM": ["https://huggingface.co/spaces/ginigen/deepseek-r1-0528-API","https://huggingface.co/spaces/aiqcamp/Mistral-Devstral-API","https://huggingface.co/spaces/aiqcamp/deepseek-r1-0528","https://huggingface.co/spaces/VIDraft/Mistral-RAG-BitSix","https://huggingface.co/spaces/ginigen/Mistral-Perflexity",],}# โโโโโโโโโโโโโโโโโโโโโโโโโโ URL HELPERS โโโโโโโโโโโโโโโโโโโโโโโโโโdef direct_url(hf_url):m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", hf_url)if not m:3 unmodified linesname = name.replace('.', '-').replace('_', '-').lower()return f"https://{owner}-{name}.hf.space"def screenshot_url(url):return f"https://image.thum.io/get/fullpage/{url}"# โโโโโโโโโโโโโโโโโโโโโโโโโโ FLASK ROUTES โโโโโโโโโโโโโโโโโโโโโโโโโโ@flask_app.route('/api/category')def api_category():cat = request.args.get('name', '')urls = CATEGORIES.get(cat, [])page = int(request.args.get('page', 1))per_page = int(request.args.get('per_page', 4))total_pages = max(1, (len(urls) + per_page - 1) // per_page)start = (page - 1) * per_pageend = 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})HTML_TEMPLATE = r'''<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Web Gallery</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;}.tab.popular{background:#ff6b6b;color:white;}.tab.popular.active{background:#fa5252;color:white;}.tab.best{background:#4ecdc4;color:white;}.tab.best.active{background:#38d9a9;color:white;}.tab.new{background:#ffe066;color:#1a202c;}.tab.new.active{background:#ffd43b;color:#1a202c;}.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;}}.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;}.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;}.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;">๐OPEN & Free: BEST AI Playground</h1><p><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><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></p></header><div class="tabs" id="tabs"></div><div id="content"></div><script>const cats = {{ cats|tojson }};const tabs = document.getElementById('tabs');const content = document.getElementById('content');let active = "";let currentPage = 1;function makeRequest(url, callback) {fetch(url).then(r => r.json()).then(callback);}function updateTabs() {Array.from(tabs.children).forEach(b => {b.classList.toggle('active', b.dataset.c === active);});}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', 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.</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>';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;});}['Popular', 'BEST', 'NEW'].forEach(specialCat => {const b = document.createElement('button');b.className = 'tab ' + specialCat.toLowerCase();b.textContent = specialCat;b.dataset.c = specialCat;b.onclick = function() { loadCategory(specialCat, 1); };tabs.appendChild(b);});cats.forEach(c => {if (!['Popular', 'BEST', 'NEW'].includes(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);}});loadCategory('Popular', 1);</script></body></html>'''@flask_app.route('/')def home():return render_template_string(HTML_TEMPLATE, cats=list(CATEGORIES.keys()))# โโโโโโโโโโโโโโโโโโโโโโโโโโ GRADIO WRAPPER โโโโโโโโโโโโโโโโโโโโโโโโโโapp = gr.mount_gradio_app(flask_app, gr.Blocks(), path="/")if __name__ == '__main__':app.launch()12345672 unmodified lines1011121314151617182 unmodified lines212223242526272829303132333435363738391 unmodified line4142434445464748495051525354555657583 unmodified lines6263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120import gradio as grimport re# โโโโโโโโโโโโโโโโโโโโโโโโโโ CATEGORIES โโโโโโโโโโโโโโโโโโโโโโโโโโCATEGORIES = {"Popular": ["https://huggingface.co/spaces/fantos/Heatmap-Leaderboard-KOREA",2 unmodified lines"https://huggingface.co/spaces/ginigen/SAJU","https://huggingface.co/spaces/ginipick/SAJU-Couple","https://huggingface.co/spaces/openfree/News-AI","https://huggingface.co/spaces/openfree/Face-blurring","https://huggingface.co/spaces/ginigen/Fashion-Fit360","https://huggingface.co/spaces/VIDraft/DNA-Diffusion","https://huggingface.co/spaces/ginigen/VEO3-Free","https://huggingface.co/spaces/ginigen/text3d-r1","https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX",2 unmodified lines"https://huggingface.co/spaces/ginipick/AGI-Personal","https://huggingface.co/spaces/ginigen/AI","https://huggingface.co/spaces/ginigen/AGI-WebToon-KOREA","https://huggingface.co/spaces/ginigen/Flux-Kontext-Style","https://huggingface.co/spaces/ginigen/Seedance-Free","https://huggingface.co/spaces/VIDraft/SOMA-AGI","https://huggingface.co/spaces/aiqtech/Heatmap-Leaderboard","https://huggingface.co/spaces/VIDraft/DNA-CASINO",],"NEW": ["https://huggingface.co/spaces/ginigen/Family","https://huggingface.co/spaces/openfree/OpenAI-gpt-oss","https://huggingface.co/spaces/ginipick/Private-AI","https://huggingface.co/spaces/VIDraft/ACE-Singer","https://huggingface.co/spaces/ginipick/AI-BOOK","https://huggingface.co/spaces/Heartsync/VEO3-RealTime",],"Multimodal": ["https://huggingface.co/spaces/ginigen/Seedance-Free",1 unmodified line"https://huggingface.co/spaces/ginigen/VEO3-Free","https://huggingface.co/spaces/ginigen/Flux-VIDEO","https://huggingface.co/spaces/VIDraft/ACE-Singer","https://huggingface.co/spaces/ginigen/VoiceClone-TTS",],"Image": ["https://huggingface.co/spaces/openfree/Face-blurring","https://huggingface.co/spaces/ginigen/Flux-Kontext-FaceLORA","https://huggingface.co/spaces/ginigen/text3d-r1","https://huggingface.co/spaces/ginipick/FLUXllama","https://huggingface.co/spaces/ginigen/MagicFace-V3","https://huggingface.co/spaces/VIDraft/stable-diffusion-3.5-large-turboX",],}def direct_url(hf_url):m = re.match(r"https?://huggingface\.co/spaces/([^/]+)/([^/?#]+)", hf_url)if not m:3 unmodified linesname = name.replace('.', '-').replace('_', '-').lower()return f"https://{owner}-{name}.hf.space"def create_gallery_html(category):urls = CATEGORIES.get(category, [])[:8] # Show first 8html = '<div style="display:grid;grid-template-columns:repeat(2,1fr);gap:20px;padding:20px;max-width:1400px;margin:0 auto;">'for url in urls:title = url.split('/')[-1]iframe_url = direct_url(url)html += f'''<div style="background:#fff;border-radius:12px;box-shadow:0 2px 8px rgba(0,0,0,.08);overflow:hidden;height:500px;display:flex;flex-direction:column;"><div style="flex:1;position:relative;overflow:hidden;background:#f5f5f5;"><div style="position:absolute;top:10px;left:10px;padding:4px 8px;border-radius:4px;background:linear-gradient(135deg,#00c6ff,#0072ff);color:white;font-size:11px;font-weight:bold;z-index:10;">LIVE</div><iframe src="{iframe_url}" style="width:100%;height:100%;border:0;" loading="lazy" sandbox="allow-forms allow-modals allow-popups allow-same-origin allow-scripts"></iframe></div><div style="padding:12px;background:#fafafa;border-top:1px solid #eee;text-align:center;"><a href="{url}" target="_blank" style="font-size:14px;font-weight:600;color:#4a6dd8;text-decoration:none;">{title}</a></div></div>'''html += '</div>'return html# Create Gradio interfacewith gr.Blocks(title="๐ BEST AI Playground",css="""@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');body {font-family: 'Nunito', sans-serif !important;}.gradio-container {max-width: 100% !important;}""") as demo:gr.HTML("""<div style="text-align:center;padding:30px 20px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:white;border-radius:10px;margin-bottom:20px;"><h1 style="margin:0 0 15px 0;font-size:2.5em;font-weight:700;">๐ BEST AI Playground</h1><p style="margin:10px 0;font-size:1.1em;">Curated Collection of Amazing AI Spaces on Hugging Face</p><div style="margin-top:20px;"><a href="https://huggingface.co/OpenFreeAI" target="_blank" style="display:inline-block;margin:5px;"><img src="https://img.shields.io/badge/Community-OpenFree_AI-purple?style=for-the-badge&logo=huggingface" alt="Community"></a><a href="https://discord.gg/openfreeai" target="_blank" style="display:inline-block;margin:5px;"><img src="https://img.shields.io/badge/Discord-Join_Us-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord"></a></div></div>""")with gr.Tabs():for category_name, urls in CATEGORIES.items():with gr.Tab(f"โจ {category_name}"):gr.HTML(create_gallery_html(category_name))if __name__ == "__main__":demo.launch()
app.py+50-201