|
from fastapi import FastAPI |
|
from titiler.core.factory import TilerFactory |
|
from titiler.stac.factory import STACTilerFactory |
|
from titiler.mosaic.factory import MosaicTilerFactory |
|
from starlette.middleware.cors import CORSMiddleware |
|
|
|
app = FastAPI( |
|
title="MPG TiTiler Endpoint", |
|
description="High-performance geospatial tile server with COG, STAC, and Mosaic support", |
|
version="1.0.0" |
|
) |
|
|
|
|
|
app.add_middleware( |
|
CORSMiddleware, |
|
allow_origins=["*"], |
|
allow_credentials=True, |
|
allow_methods=["*"], |
|
allow_headers=["*"], |
|
) |
|
|
|
|
|
cog = TilerFactory() |
|
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"]) |
|
|
|
|
|
stac = STACTilerFactory() |
|
app.include_router(stac.router, prefix="/stac", tags=["STAC Items"]) |
|
|
|
|
|
mosaic = MosaicTilerFactory() |
|
app.include_router(mosaic.router, prefix="/mosaic", tags=["MosaicJSON"]) |
|
|
|
|
|
@app.get("/") |
|
def read_index(): |
|
return { |
|
"message": "Welcome to MPG TiTiler Endpoint", |
|
"description": "High-performance geospatial tile server", |
|
"endpoints": { |
|
"cog": "Cloud Optimized GeoTIFF tiling", |
|
"stac": "STAC item tiling (prefix: /stac)", |
|
"mosaic": "MosaicJSON tiling (prefix: /mosaic)" |
|
}, |
|
"docs": "/docs", |
|
"health": "/health" |
|
} |
|
|
|
@app.get("/health") |
|
def health_check(): |
|
return {"status": "healthy", "service": "titiler"} |