Automated Action 2e449f5437 Add Hello World FastAPI application with health endpoint
generated with BackendIM... (backend.im)
2025-05-13 05:23:42 +00:00

38 lines
842 B
Python

from fastapi import FastAPI
from pathlib import Path
from sqlalchemy import create_engine
import uvicorn
app = FastAPI(
title="Hello World API",
description="A simple FastAPI hello world application",
version="0.1.0"
)
# Setup database
DB_DIR = Path("/app") / "storage" / "db"
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
@app.get("/")
def read_root():
return {"message": "Hello World"}
@app.get("/health", tags=["health"])
def health_check():
"""
Health check endpoint
"""
return {
"status": "healthy",
"api_version": app.version
}
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)