app = Flask(__name__)
fetch(`/search?q=$encodeURIComponent(query)`) .then(r => r.json()) .then(data => if (data.error) document.getElementById('results').innerText = "Error: " + data.error; return; const container = document.getElementById('results'); data.videos.forEach(v => const card = document.createElement('div'); card.className = 'video-card'; card.innerHTML = ` <img src="$v.thumb" alt="thumb"> <div> <strong>$v.title</strong><br> <small>Channel: $v.channel<br> Published: $new Date(v.published).toLocaleDateString()</small> </div>`; card.onclick = () => loadVideo(v.video_id); container.appendChild(card); ); ) .catch(err => document.getElementById('results').innerText = "Fetch error: " + err; ); havoc brother song tamil latest
# ---------------------------------------------------------------------- # Routes # ---------------------------------------------------------------------- @app.route("/", methods=["GET"]) def index(): # Render empty page – the UI will fetch results via AJAX. return render_template("index.html") app = Flask(__name__) fetch(`/search
@app.route("/search", methods=["GET"]) def search(): q = request.args.get("q", "") if not q: return jsonify("error": "missing query"), 400 try: videos = youtube_search(q) return jsonify("videos": videos) except Exception as exc: return jsonify("error": str(exc)), 500 r.json()) .then(data =>
<script> // Auto‑run the query on page load const query = "havoc brother song tamil latest";
<div id="results"></div>