Automated Action 606cda0912 Implement Blogging API with FastAPI and SQLite
- Create project structure with app organization
- Set up FastAPI application with CORS and health endpoint
- Implement database models with SQLAlchemy (User, Post, Comment)
- Set up Alembic for database migrations
- Implement authentication with JWT tokens
- Create CRUD operations for all models
- Implement REST API endpoints for users, posts, and comments
- Add comprehensive documentation in README.md
2025-06-02 22:34:58 +00:00

39 lines
856 B
Python

import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1.api import api_router
from app.core.config import settings
app = FastAPI(
title=settings.PROJECT_NAME,
description="Blogging API with FastAPI and SQLite",
version="0.1.0",
docs_url="/docs",
redoc_url="/redoc",
openapi_url="/openapi.json",
)
# Set all CORS enabled origins
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include API router
app.include_router(api_router)
# Health check endpoint
@app.get("/health", tags=["health"])
async def health_check():
return {"status": "ok"}
if __name__ == "__main__":
uvicorn.run(
"main:app",
host="0.0.0.0",
port=8000,
reload=True,
)