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