| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Asset Extractor API — Test Panel</title> |
| <style> |
| :root{ |
| --bg:#0f1115; --panel:#161a22; --panel2:#1c212b; --border:#2a3040; |
| --text:#e6e9ef; --muted:#8b93a7; --accent:#4f8cff; --accent2:#34d399; |
| --danger:#f87171; --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; |
| } |
| *{box-sizing:border-box} |
| body{margin:0;background:var(--bg);color:var(--text); |
| font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;line-height:1.5} |
| header{padding:18px 24px;border-bottom:1px solid var(--border); |
| display:flex;align-items:center;gap:16px;flex-wrap:wrap; |
| position:sticky;top:0;background:var(--bg);z-index:5} |
| header h1{font-size:18px;margin:0;font-weight:600} |
| header .sub{color:var(--muted);font-size:13px} |
| .base{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap} |
| .base label{color:var(--muted);font-size:13px} |
| main{padding:24px;max-width:860px;margin:0 auto;display:flex;flex-direction:column;gap:20px} |
| .card{background:var(--panel);border:1px solid var(--border);border-radius:12px; |
| padding:16px;display:flex;flex-direction:column;gap:12px} |
| .card h2{font-size:14px;margin:0;letter-spacing:.02em;display:flex; |
| align-items:center;gap:8px} |
| .method{font-family:var(--mono);font-size:11px;padding:2px 8px;border-radius:6px; |
| font-weight:600} |
| .post{background:rgba(52,211,153,.15);color:#5eead4} |
| .path{font-family:var(--mono);font-size:12px;color:var(--muted)} |
| .field{display:flex;flex-direction:column;gap:5px} |
| .field label{font-size:12px;color:var(--muted)} |
| .row{display:flex;gap:10px;flex-wrap:wrap} |
| .check{flex-direction:row;align-items:center;gap:8px} |
| .check input{accent-color:var(--accent);width:16px;height:16px} |
| input,button{ |
| background:var(--panel2);color:var(--text);border:1px solid var(--border); |
| border-radius:8px;padding:8px 10px;font-size:13px;font-family:inherit;outline:none} |
| input:focus{border-color:var(--accent)} |
| input[type=url]{width:100%} |
| .actions{display:flex;gap:8px;align-items:center;margin-top:2px} |
| button.run{background:var(--accent);color:#fff;border:none;font-weight:600;cursor:pointer} |
| button.run:hover{filter:brightness(1.08)} |
| button.run:disabled{opacity:.6;cursor:wait} |
| .status{font-family:var(--mono);font-size:12px;border-radius:8px;padding:8px 10px; |
| background:var(--panel2)} |
| .status.ok{color:var(--accent2)} |
| .status.err{color:var(--danger,#f87171)} |
| .status.wait{color:var(--muted)} |
| pre.js{background:#0a0d12;border:1px solid var(--border);border-radius:8px; |
| padding:12px;font-family:var(--mono);font-size:12px;overflow:auto; |
| max-height:400px;margin:0;white-space:pre-wrap;word-break:break-word} |
| .group{display:flex;flex-direction:column;gap:6px} |
| .group h3{font-size:12px;margin:0;color:var(--muted);text-transform:uppercase; |
| letter-spacing:.05em} |
| .group .links{display:flex;flex-direction:column;gap:2px} |
| .group a{color:#7aa9ff;text-decoration:none;font-family:var(--mono); |
| font-size:12px;word-break:break-all} |
| .group a:hover{text-decoration:underline} |
| </style> |
| </head> |
| <body> |
| <header> |
| <h1>Asset Extractor API <span class="sub">· test panel</span></h1> |
| <div class="base"> |
| <label for="base">API base</label> |
| <input type="url" id="base" value="https://lljz66-api.hf.space" style="width:320px" spellcheck="false"> |
| </div> |
| </header> |
|
|
| <main> |
| <section class="card"> |
| <h2><span class="method post">POST</span><span class="path">/assets</span></h2> |
| <div class="field"><label>url</label> |
| <input type="url" id="a_url" value="https://example.com" spellcheck="false"></div> |
| <div class="field check"><input type="checkbox" id="a_data"> |
| <label for="a_data">include data: URIs</label></div> |
| <div class="actions"><button class="run" id="aRun">Run</button></div> |
| <div class="status" id="a_status">not run</div> |
| <div class="title" id="a_title"></div> |
| <pre class="js" id="aOut">—</pre> |
| </section> |
| </main> |
|
|
| <script> |
| const $ = id => document.getElementById(id); |
| function baseUrl(){ return $('base').value.replace(/\/+$/,''); } |
| async function req(path, opts){ |
| const res = await fetch(baseUrl() + path, opts); |
| const text = await res.text(); |
| let body; try{ body = JSON.parse(text); }catch(e){ body = text; } |
| return {ok:res.ok, status:res.status, body}; |
| } |
| function showStatus(el, kind, msg){ el.className='status '+kind; el.textContent=msg; } |
| const fmt = o => JSON.stringify(o,null,2); |
| |
| async function runAssets(){ |
| const st=$('a_status'), ti=$('a_title'), out=$('aOut'), btn=$('aRun'); |
| btn.disabled=true; |
| showStatus(st,'wait','extracting…'); ti.textContent=''; out.textContent='—'; |
| try{ |
| const r=await req('/assets',{method:'POST',headers:{'Content-Type':'application/json'}, |
| body:JSON.stringify({url:$('a_url').value.trim(), include_data_uris:$('a_data').checked})}); |
| out.style.display='block'; out.textContent=fmt(r.body); |
| if(r.ok){ |
| showStatus(st,'ok','HTTP '+r.status+' · '+r.body.total+' assets'); |
| ti.textContent = r.body.title? 'Title: '+r.body.title : ''; |
| }else{ |
| showStatus(st,'err','HTTP '+r.status+' · '+((r.body&&r.body.detail)?r.body.detail:JSON.stringify(r.body))); |
| } |
| }catch(e){ showStatus(st,'err','network error: '+e.message); } |
| btn.disabled=false; |
| } |
| |
| $('aRun').onclick=runAssets; |
| $('a_url').addEventListener('keydown',e=>{if(e.key==='Enter')runAssets();}); |
| </script> |
| </body> |
| </html> |
|
|