Automated Action cd7c0162fe Create REST API with FastAPI and SQLite
- Implemented project structure with FastAPI framework
- Set up SQLite database with SQLAlchemy ORM
- Created Alembic for database migrations
- Implemented Item model and CRUD operations
- Added health check endpoint
- Added error handling
- Configured API documentation with Swagger UI

generated with BackendIM... (backend.im)
2025-05-13 15:58:51 +00:00

34 lines
783 B
Python

import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import api_router
from app.database import Base, engine
from app.errors import add_error_handlers
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Generic REST API Service",
description="A simple REST API service built with FastAPI and SQLite",
version="0.1.0",
)
# Set up CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Add error handlers
add_error_handlers(app)
# Include API router
app.include_router(api_router)
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)