Spaces:
Sleeping
Sleeping
Srinivasulu kethanaboina
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,27 @@
|
|
1 |
from fastapi import FastAPI, Request
|
|
|
|
|
|
|
2 |
|
3 |
app = FastAPI()
|
4 |
|
5 |
@app.get("/")
|
6 |
async def read_root(request: Request):
|
7 |
client_ip = request.client.host
|
8 |
-
|
9 |
-
return {"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI, Request
|
2 |
+
import logging
|
3 |
+
import gradio as gr
|
4 |
+
from threading import Thread
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
8 |
@app.get("/")
|
9 |
async def read_root(request: Request):
|
10 |
client_ip = request.client.host
|
11 |
+
logging.info(f'Client IP Address: {client_ip}')
|
12 |
+
return {"Client IP Address": client_ip}
|
13 |
+
|
14 |
+
def gradio_interface():
|
15 |
+
def greet(name):
|
16 |
+
return f"Hello {name}!"
|
17 |
+
|
18 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
19 |
+
iface.launch()
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
# Run FastAPI app
|
23 |
+
from uvicorn import run
|
24 |
+
Thread(target=lambda: run(app, host="0.0.0.0", port=8000)).start()
|
25 |
+
|
26 |
+
# Run Gradio app
|
27 |
+
gradio_interface()
|