Spaces:
Sleeping
Sleeping
Create your_module.py
Browse files- your_module.py +36 -0
your_module.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, status
|
2 |
+
from pydantic import BaseModel
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Define your response model
|
6 |
+
class HealthCheck(BaseModel):
|
7 |
+
status: str = "healthy"
|
8 |
+
|
9 |
+
# Create FastAPI app
|
10 |
+
app = FastAPI()
|
11 |
+
|
12 |
+
# Add health check endpoint
|
13 |
+
@app.get(
|
14 |
+
"/health",
|
15 |
+
tags=["healthcheck"],
|
16 |
+
summary="Perform a Health Check",
|
17 |
+
response_description="Return HTTP Status Code 200 (OK)",
|
18 |
+
status_code=status.HTTP_200_OK,
|
19 |
+
response_model=HealthCheck
|
20 |
+
)
|
21 |
+
def get_health() -> HealthCheck:
|
22 |
+
"""
|
23 |
+
Health Check Endpoint
|
24 |
+
|
25 |
+
This endpoint provides a simple status check to verify the API is running.
|
26 |
+
"""
|
27 |
+
return HealthCheck(status="healthy")
|
28 |
+
|
29 |
+
# Create your Gradio interface
|
30 |
+
def greet(name):
|
31 |
+
return "Hello, " + name + "!"
|
32 |
+
|
33 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
34 |
+
|
35 |
+
# Mount the Gradio app to the FastAPI app
|
36 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|