mgokg commited on
Commit
aee6311
·
verified ·
1 Parent(s): 24ad0b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -24
app.py CHANGED
@@ -5,8 +5,6 @@ from urllib.parse import urljoin
5
 
6
  def parse_links(ort):
7
  try:
8
- # Konstruiere die vollständige URL
9
- initial_url = "http://specialist-it.de:3000?q=hallo"
10
  import requests
11
 
12
  url = "http://specialist-it.de:3001/api/search"
@@ -37,24 +35,6 @@ def parse_links(ort):
37
 
38
  print(response.json())
39
  return response.json()
40
-
41
-
42
- # Senden der Anfrage an die initiale URL
43
- response = requests.get(initial_url)
44
- response.raise_for_status() # Überprüfen, ob die Anfrage erfolgreich war
45
-
46
- # Parse the HTML content using BeautifulSoup
47
- soup = BeautifulSoup(response.content, 'html.parser')
48
-
49
- # Den body-Tag finden
50
- body_tag = soup.find('body')
51
-
52
- # Den Text des body-Tags zurückgeben
53
- body_text = body_tag.get_text()
54
-
55
- # Den Text ausgeben
56
- print(body_text)
57
- return body_text
58
  # Rückgabe als Dictionary, um es mit gr.JSON kompatibel zu machen
59
  #return {"body_text": body_text}
60
 
@@ -65,11 +45,11 @@ def parse_links(ort):
65
 
66
  # Erstelle die Gradio-Schnittstelle
67
  with gr.Blocks() as demo:
68
- gr.Markdown("# Vereine in Bayern")
69
- ort_input = gr.Textbox(label="Ort", placeholder="Gib den Namen des Ortes ein")
70
- links_output = gr.JSON(label="Gefundene Vereine")
71
  # Button zum Starten der Parsung
72
- button = gr.Button("Parse und Scrape")
73
  # Verbinde den Button mit der Funktion
74
  button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
75
 
 
5
 
6
  def parse_links(ort):
7
  try:
 
 
8
  import requests
9
 
10
  url = "http://specialist-it.de:3001/api/search"
 
35
 
36
  print(response.json())
37
  return response.json()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  # Rückgabe als Dictionary, um es mit gr.JSON kompatibel zu machen
39
  #return {"body_text": body_text}
40
 
 
45
 
46
  # Erstelle die Gradio-Schnittstelle
47
  with gr.Blocks() as demo:
48
+ gr.Markdown("# Perplexica WebSearch")
49
+ ort_input = gr.Textbox(label="Ort", placeholder="prompt")
50
+ links_output = gr.JSON(label="Antwort")
51
  # Button zum Starten der Parsung
52
+ button = gr.Button("senden")
53
  # Verbinde den Button mit der Funktion
54
  button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
55