endpointwebappshl / your_module.py
AnshulS's picture
Create your_module.py
2cb1a3c verified
raw
history blame contribute delete
896 Bytes
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="/")