Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from pydantic import BaseModel
|
|
| 6 |
import gradio as gr
|
| 7 |
import uvicorn
|
| 8 |
|
| 9 |
-
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
class Numbers(BaseModel):
|
|
@@ -43,15 +43,15 @@ def multiply_numbers(x: float, y: float) -> float:
|
|
| 43 |
def divide_numbers(x: float, y: float) -> float:
|
| 44 |
return x / y
|
| 45 |
|
| 46 |
-
|
| 47 |
def run_fastapi():
|
| 48 |
uvicorn.run(app, host="127.0.0.1", port=8000)
|
| 49 |
|
| 50 |
-
|
| 51 |
thread = threading.Thread(target=run_fastapi, daemon=True)
|
| 52 |
thread.start()
|
| 53 |
|
| 54 |
-
|
| 55 |
BASE_URL = "http://127.0.0.1:8000"
|
| 56 |
|
| 57 |
def perform_operation(operation: str, x: float, y: float) -> str:
|
|
@@ -64,7 +64,7 @@ def perform_operation(operation: str, x: float, y: float) -> str:
|
|
| 64 |
except requests.exceptions.HTTPError as err:
|
| 65 |
return f"Error: {err.response.json().get('detail')}"
|
| 66 |
|
| 67 |
-
|
| 68 |
iface = gr.Interface(
|
| 69 |
fn=perform_operation,
|
| 70 |
inputs=[
|
|
@@ -76,6 +76,6 @@ iface = gr.Interface(
|
|
| 76 |
live=False
|
| 77 |
)
|
| 78 |
|
| 79 |
-
|
| 80 |
time.sleep(1)
|
| 81 |
iface.launch()
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import uvicorn
|
| 8 |
|
| 9 |
+
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
class Numbers(BaseModel):
|
|
|
|
| 43 |
def divide_numbers(x: float, y: float) -> float:
|
| 44 |
return x / y
|
| 45 |
|
| 46 |
+
|
| 47 |
def run_fastapi():
|
| 48 |
uvicorn.run(app, host="127.0.0.1", port=8000)
|
| 49 |
|
| 50 |
+
|
| 51 |
thread = threading.Thread(target=run_fastapi, daemon=True)
|
| 52 |
thread.start()
|
| 53 |
|
| 54 |
+
|
| 55 |
BASE_URL = "http://127.0.0.1:8000"
|
| 56 |
|
| 57 |
def perform_operation(operation: str, x: float, y: float) -> str:
|
|
|
|
| 64 |
except requests.exceptions.HTTPError as err:
|
| 65 |
return f"Error: {err.response.json().get('detail')}"
|
| 66 |
|
| 67 |
+
|
| 68 |
iface = gr.Interface(
|
| 69 |
fn=perform_operation,
|
| 70 |
inputs=[
|
|
|
|
| 76 |
live=False
|
| 77 |
)
|
| 78 |
|
| 79 |
+
|
| 80 |
time.sleep(1)
|
| 81 |
iface.launch()
|