rr19tech commited on
Commit
b8f3d7e
·
verified ·
1 Parent(s): 7e4d4dd
Files changed (1) hide show
  1. app.py +6 -15
app.py CHANGED
@@ -1,32 +1,23 @@
 
1
  from fastapi import FastAPI
2
  import gradio as gr
3
  from pydantic import BaseModel
4
 
5
  app = FastAPI()
6
 
7
- # 1. Define the incoming JSON structure
8
  class ApiInput(BaseModel):
9
- user_string: str # The key name you want to use in your JSON payload
10
 
11
- # 2. Setup your POST route
12
  @app.post("/call_private_api")
13
  def call_private_api(payload: ApiInput):
14
- # Extract the string value from the request
15
  input_text = payload.user_string
16
-
17
- # Run your custom processing logic here
18
- processed_result = f"Received and processed: {input_text}"
19
-
20
- return {"result": processed_result}
21
 
22
- # 3. Mount your standard Gradio interface
23
  with gr.Blocks() as demo:
24
  gr.Markdown("# My Space Interface")
25
 
26
  app = gr.mount_gradio_app(app, demo, path="/")
27
 
28
-
29
-
30
-
31
-
32
-
 
1
+ import uvicorn
2
  from fastapi import FastAPI
3
  import gradio as gr
4
  from pydantic import BaseModel
5
 
6
  app = FastAPI()
7
 
 
8
  class ApiInput(BaseModel):
9
+ user_string: str
10
 
 
11
  @app.post("/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("# My Space Interface")
18
 
19
  app = gr.mount_gradio_app(app, demo, path="/")
20
 
21
+ # --- ADD THIS RUN BLOCK AT THE BOTTOM ---
22
+ if __name__ == "__main__":
23
+ uvicorn.run(app, host="0.0.0.0", port=7860)