
* Created FastAPI application structure * Added database models for assets, exchanges, markets, and rates * Integrated with CoinCap API * Implemented REST API endpoints * Setup SQLite persistence with Alembic migrations * Added comprehensive documentation Generated with BackendIM... (backend.im)
36 lines
983 B
Python
36 lines
983 B
Python
import uvicorn
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from pathlib import Path
|
|
|
|
from app.api.routes import api_router
|
|
from app.core.config import settings
|
|
from app.core.database import engine, Base
|
|
|
|
# Create database tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
# Initialize FastAPI app
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json",
|
|
description="A REST API service for cryptocurrency data powered by CoinCap",
|
|
version="0.1.0",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # Allows all origins for development purposes
|
|
allow_credentials=True,
|
|
allow_methods=["*"], # Allows all methods
|
|
allow_headers=["*"], # Allows all headers
|
|
)
|
|
|
|
# Include API router
|
|
app.include_router(api_router)
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |