Update app.py
Browse files
app.py
CHANGED
|
@@ -217,17 +217,22 @@ def read_root():
|
|
| 217 |
</html>
|
| 218 |
"""
|
| 219 |
|
| 220 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
def show_data():
|
| 222 |
return json.dumps(lists, indent=4) # Return the data as formatted JSON
|
| 223 |
|
| 224 |
-
# Gradio
|
| 225 |
-
|
| 226 |
|
| 227 |
-
#
|
| 228 |
-
app = gr.mount_gradio_app(app,
|
| 229 |
|
| 230 |
-
#
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
| 217 |
</html>
|
| 218 |
"""
|
| 219 |
|
| 220 |
+
# FastAPI endpoint to get data
|
| 221 |
+
@app.get("/gradio/data")
|
| 222 |
+
async def get_data():
|
| 223 |
+
return lists
|
| 224 |
+
|
| 225 |
+
# Define Gradio interface
|
| 226 |
def show_data():
|
| 227 |
return json.dumps(lists, indent=4) # Return the data as formatted JSON
|
| 228 |
|
| 229 |
+
# Create the Gradio interface
|
| 230 |
+
gradio_app = gr.Interface(fn=show_data, inputs=[], outputs="text")
|
| 231 |
|
| 232 |
+
# Mount the Gradio app to FastAPI
|
| 233 |
+
app = gr.mount_gradio_app(app, gradio_app, path="/gradio")
|
| 234 |
|
| 235 |
+
# Add this if you're running this script directly
|
| 236 |
+
if __name__ == "__main__":
|
| 237 |
+
import uvicorn
|
| 238 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|