Srinivasulu kethanaboina commited on
Commit
0a9fac2
·
verified ·
1 Parent(s): 7f88d32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -1,20 +1,12 @@
1
- from flask import Flask, request
2
  import gradio as gr
3
 
4
- app = Flask(__name__)
5
 
6
- def get_ip():
7
- # Retrieve the client's IP address
8
- client_ip = request.remote_addr
9
- return f"Client IP Address: {client_ip}"
 
10
 
11
- # Define the Gradio interface
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)