from flask import Flask, render_template, request, redirect, url_for, jsonify, session, Response import requests import os from datetime import timedelta app = Flask(__name__) app.secret_key = os.urandom(24) # Session encryption key app.permanent_session_lifetime = timedelta(days=7) # Session duration # Huggingface URL list HUGGINGFACE_URLS = [ "https://huggingface.co/spaces/ginipick/Tech_Hangman_Game", "https://huggingface.co/spaces/openfree/deepseek_r1_API", "https://huggingface.co/spaces/ginipick/open_Deep-Research", "https://huggingface.co/spaces/aiqmaster/open-deep-research", "https://huggingface.co/spaces/seawolf2357/DeepSeek-R1-32b-search", "https://huggingface.co/spaces/ginigen/LLaDA", "https://huggingface.co/spaces/VIDraft/PHI4-Multimodal", "https://huggingface.co/spaces/ginigen/Ovis2-8B", "https://huggingface.co/spaces/ginigen/Graph-Mind", "https://huggingface.co/spaces/ginigen/Workflow-Canvas", "https://huggingface.co/spaces/ginigen/Design", "https://huggingface.co/spaces/ginigen/Diagram", "https://huggingface.co/spaces/ginigen/Mockup", "https://huggingface.co/spaces/ginigen/Infographic", "https://huggingface.co/spaces/ginigen/Flowchart", "https://huggingface.co/spaces/aiqcamp/FLUX-Vision", "https://huggingface.co/spaces/ginigen/VoiceClone-TTS", "https://huggingface.co/spaces/openfree/Perceptron-Network", "https://huggingface.co/spaces/openfree/Article-Generator", ] # Extract title from the last part of URL def extract_title(url): parts = url.split("/") title = parts[-1] if parts else "" return title.replace("_", " ").replace("-", " ") # Huggingface token validation def validate_token(token): headers = {"Authorization": f"Bearer {token}"} # Try whoami-v2 endpoint first try: response = requests.get("https://huggingface.co/api/whoami-v2", headers=headers) if response.ok: return True, response.json() except Exception as e: print(f"whoami-v2 token validation error: {e}") # Try the original whoami endpoint try: response = requests.get("https://huggingface.co/api/whoami", headers=headers) if response.ok: return True, response.json() except Exception as e: print(f"whoami token validation error: {e}") return False, None # Create a redirect page for each URL def create_frame_page(url, title): return f'''