SearXNG2 / app.py
Timo123432345443's picture
Create app.py
33661a5 verified
raw
history blame contribute delete
584 Bytes
import gradio as gr
import requests
def search(q):
r = requests.get(
"http://127.0.0.1:8080/search",
params={"q": q, "format": "json"},
timeout=10
)
results = r.json().get("results", [])
return "\n\n".join(
f"{r['title']}\n{r['url']}"
for r in results[:5]
) or "😿 Keine Treffer"
with gr.Blocks() as demo:
gr.Markdown("## 🐾 Willy's SearXNG Space")
q = gr.Textbox(label="Suche")
out = gr.Textbox(lines=15)
gr.Button("Suchen").click(search, q, out)
demo.launch(server_name="0.0.0.0", server_port=7860)