Updated to pure gradio method
Browse files
app.py
CHANGED
|
@@ -1,23 +1,16 @@
|
|
| 1 |
-
import uvicorn
|
| 2 |
-
from fastapi import FastAPI
|
| 3 |
import gradio as gr
|
| 4 |
-
from pydantic import BaseModel
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
user_string: str
|
| 10 |
-
|
| 11 |
-
@app.post("/api/call_private_api")
|
| 12 |
-
def call_private_api(payload: ApiInput):
|
| 13 |
-
input_text = payload.user_string
|
| 14 |
-
return {"result": f"Processed: {input_text}"}
|
| 15 |
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
-
gr.Markdown("#
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
# --- ADD THIS RUN BLOCK AT THE BOTTOM ---
|
| 22 |
-
if __name__ == "__main__":
|
| 23 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
def call_private_api(user_input: str) -> str:
|
| 4 |
+
# Your processing logic
|
| 5 |
+
return f"Processed query: {user_input}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
with gr.Blocks() as demo:
|
| 8 |
+
gr.Markdown("# Production API Server")
|
| 9 |
+
|
| 10 |
+
# Expose the logic safely to the Gradio pipeline architecture
|
| 11 |
+
gr.api(fn=call_private_api, api_name="call_private_api")
|
| 12 |
|
| 13 |
+
# Force execution via queue (Crucial for bypassing Edge updates)
|
| 14 |
+
demo.queue()
|
| 15 |
+
demo.launch()
|
| 16 |
|
|
|
|
|
|
|
|
|