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

23 lines
518 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
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}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()