Automated Action 79eb3ef108 Add complete Uptime Monitoring API implementation
- Created FastAPI application with SQLite database
- Implemented monitor management endpoints (CRUD operations)
- Added uptime checking functionality with response time tracking
- Included statistics endpoints for uptime percentage and metrics
- Set up database models and Alembic migrations
- Added comprehensive API documentation
- Configured CORS and health check endpoints
2025-06-19 20:40:47 +00:00

48 lines
1.1 KiB
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.db.session import engine
from app.db.base import Base
from app.routers import monitors, checks
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Uptime Monitoring API",
description="API for monitoring website/endpoint uptime and performance",
version="1.0.0",
openapi_url="/openapi.json",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(monitors.router, prefix="/api/v1")
app.include_router(checks.router, prefix="/api/v1")
@app.get("/")
async def root():
return {
"title": "Uptime Monitoring API",
"documentation": "/docs",
"health_check": "/health",
}
@app.get("/health")
async def health_check():
return {"status": "healthy", "service": "uptime-monitoring-api"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)