Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,11 @@ from pydantic import BaseModel
|
|
3 |
import gradio as gr
|
4 |
import uvicorn
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
-
#
|
10 |
app.add_middleware(
|
11 |
CORSMiddleware,
|
12 |
allow_origins=["*"],
|
@@ -26,7 +27,7 @@ async def create_item(item: Item):
|
|
26 |
zeitstempel = item.zeitstempel
|
27 |
return {"prompt": prompt, "zeitstempel": zeitstempel}
|
28 |
|
29 |
-
#
|
30 |
prompt = ""
|
31 |
|
32 |
def get_prompt():
|
@@ -34,12 +35,14 @@ def get_prompt():
|
|
34 |
|
35 |
gr_interface = gr.Interface(fn=get_prompt, inputs=[], outputs="text", live=True)
|
36 |
|
37 |
-
|
38 |
-
|
39 |
|
40 |
@app.get("/")
|
41 |
def read_root():
|
42 |
-
return {"message": "
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
-
|
|
|
|
|
|
3 |
import gradio as gr
|
4 |
import uvicorn
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
6 |
+
import threading
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
10 |
+
# Erlaube alle Ursprünge
|
11 |
app.add_middleware(
|
12 |
CORSMiddleware,
|
13 |
allow_origins=["*"],
|
|
|
27 |
zeitstempel = item.zeitstempel
|
28 |
return {"prompt": prompt, "zeitstempel": zeitstempel}
|
29 |
|
30 |
+
# Initialer Wert für prompt
|
31 |
prompt = ""
|
32 |
|
33 |
def get_prompt():
|
|
|
35 |
|
36 |
gr_interface = gr.Interface(fn=get_prompt, inputs=[], outputs="text", live=True)
|
37 |
|
38 |
+
def start_gradio():
|
39 |
+
gr_interface.launch()
|
40 |
|
41 |
@app.get("/")
|
42 |
def read_root():
|
43 |
+
return {"message": "Willkommen am Root-Endpunkt."}
|
44 |
|
45 |
if __name__ == "__main__":
|
46 |
+
# Starte Gradio in einem separaten Thread
|
47 |
+
threading.Thread(target=start_gradio).start()
|
48 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|