Spaces:
Sleeping
Sleeping
Srinivasulu kethanaboina commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,12 @@
|
|
| 1 |
-
from
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
app =
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
client_ip = request.
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
interface = gr.Interface(fn=get_ip, inputs=[], outputs="text")
|
| 13 |
-
|
| 14 |
-
@app.route('/')
|
| 15 |
-
def index():
|
| 16 |
-
# Launch Gradio interface on the Flask route
|
| 17 |
-
return interface.launch(share=True)
|
| 18 |
-
|
| 19 |
-
if __name__ == '__main__':
|
| 20 |
-
app.run(debug=True)
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
app = FastAPI()
|
| 5 |
|
| 6 |
+
@app.post("/predict")
|
| 7 |
+
async def predict(request: Request):
|
| 8 |
+
client_ip = request.client.host
|
| 9 |
+
# Now you can use client_ip as needed
|
| 10 |
+
return {"client_ip": client_ip}
|
| 11 |
|
| 12 |
+
gr.Interface(fn=predict, inputs="text", outputs="text").launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|