mgokg commited on
Commit
60e48ff
·
verified ·
1 Parent(s): 0bc6d47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -1,5 +1,4 @@
1
- from fastapi import FastAPI, Request
2
- from fastapi.responses import HTMLResponse
3
  from pydantic import BaseModel
4
  import gradio as gr
5
  import uvicorn
@@ -15,6 +14,7 @@ app.add_middleware(
15
  allow_credentials=True,
16
  allow_methods=["*"],
17
  allow_headers=["*"],
 
18
  )
19
 
20
  class Item(BaseModel):
@@ -34,31 +34,32 @@ prompt = ""
34
  def get_prompt(prompt):
35
  return prompt
36
 
37
- @app.get("/fa.html")
38
- async def read_index():
39
- with open("index.html", "r") as f:
40
- return HTMLResponse(content=f.read(), status_code=200)
41
 
42
- @app.get("/")
43
- def read_root():
44
- return {"message": "Willkommen am Root-Endpunkt."}
45
 
46
  with gr.Blocks() as demo:
47
- gr.HTML(src="http://localhost:8000/fa.html", width="100%", height="600px")
48
- with gr.Row():
49
- details_output = gr.Textbox(label="Ausgabe")
50
  with gr.Row():
51
- ort_input = gr.Textbox(label="", placeholder="ask anything...")
 
52
  with gr.Row():
53
- button = gr.Button("Senden")
 
 
54
 
55
  # Connect the button to the function
56
- button.click(fn=get_prompt, inputs=ort_input, outputs=details_output)
57
 
58
  # Launch the Gradio application
59
  demo.launch()
60
 
61
 
 
 
 
 
62
  if __name__ == "__main__":
63
  # Starte Gradio in einem separaten Thread
64
  threading.Thread(target=start_gradio).start()
 
1
+ from fastapi import FastAPI
 
2
  from pydantic import BaseModel
3
  import gradio as gr
4
  import uvicorn
 
14
  allow_credentials=True,
15
  allow_methods=["*"],
16
  allow_headers=["*"],
17
+
18
  )
19
 
20
  class Item(BaseModel):
 
34
  def get_prompt(prompt):
35
  return prompt
36
 
 
 
 
 
37
 
38
+ def show_html():
39
+ return """
40
+ """
41
 
42
  with gr.Blocks() as demo:
43
+ gr.HTML(show_html)
 
 
44
  with gr.Row():
45
+ #details_output = gr.DataFrame(label="Ausgabe", elem_id="md")
46
+ details_output = gr.Textbox(label="Ausgabe")
47
  with gr.Row():
48
+ ort_input = gr.Textbox(label="", placeholder="ask anything...")
49
+ with gr.Row():
50
+ button = gr.Button("Senden")
51
 
52
  # Connect the button to the function
53
+ button.click(fn=get_prompt, inputs=ort_input, outputs=details_output)
54
 
55
  # Launch the Gradio application
56
  demo.launch()
57
 
58
 
59
+ @app.get("/")
60
+ def read_root():
61
+ return {"message": "Willkommen am Root-Endpunkt."}
62
+
63
  if __name__ == "__main__":
64
  # Starte Gradio in einem separaten Thread
65
  threading.Thread(target=start_gradio).start()