
- Created customer, driver, and order models with SQLAlchemy - Implemented CRUD API endpoints for all entities - Set up SQLite database with Alembic migrations - Added health check and base URL endpoints - Configured CORS middleware for all origins - Updated README with comprehensive documentation
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.routes import customers_router, drivers_router, orders_router
|
|
from app.db.session import engine
|
|
from app.db.base import Base
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Delivery Business API",
|
|
description="A simple API backend for a delivery business",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json"
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"title": "Delivery Business API",
|
|
"description": "A simple API backend for a delivery business",
|
|
"documentation": "/docs",
|
|
"health_check": "/health"
|
|
}
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy", "service": "Delivery Business API"}
|
|
|
|
app.include_router(customers_router, prefix="/api/v1/customers", tags=["customers"])
|
|
app.include_router(drivers_router, prefix="/api/v1/drivers", tags=["drivers"])
|
|
app.include_router(orders_router, prefix="/api/v1/orders", tags=["orders"])
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |