Spaces:
Running
Running
Add ROOT Path
Browse files- Dockerfile +1 -0
- main.py +36 -0
Dockerfile
CHANGED
|
@@ -3,6 +3,7 @@ FROM ghcr.io/developmentseed/titiler:latest
|
|
| 3 |
# Optional: Set CORS options (defaults to "*", so only needed if customizing)
|
| 4 |
ENV TITILER_API_CORS_ORIGINS=*
|
| 5 |
ENV TITILER_API_CORS_ALLOW_METHODS=GET,POST,OPTIONS
|
|
|
|
| 6 |
|
| 7 |
EXPOSE 7860
|
| 8 |
|
|
|
|
| 3 |
# Optional: Set CORS options (defaults to "*", so only needed if customizing)
|
| 4 |
ENV TITILER_API_CORS_ORIGINS=*
|
| 5 |
ENV TITILER_API_CORS_ALLOW_METHODS=GET,POST,OPTIONS
|
| 6 |
+
ENV TITILER_API_ROOT_PATH=""
|
| 7 |
|
| 8 |
EXPOSE 7860
|
| 9 |
|
main.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from titiler.core.factory import TilerFactory
|
| 3 |
+
from titiler.stac.factory import STACTilerFactory
|
| 4 |
+
from titiler.mosaic.factory import MosaicTilerFactory
|
| 5 |
+
from titiler.mosaic.routes import MosaicRouter
|
| 6 |
+
from titiler.core.dependencies import DefaultDependency
|
| 7 |
+
from starlette.middleware.cors import CORSMiddleware
|
| 8 |
+
|
| 9 |
+
app = FastAPI()
|
| 10 |
+
|
| 11 |
+
# Enable CORS
|
| 12 |
+
app.add_middleware(
|
| 13 |
+
CORSMiddleware,
|
| 14 |
+
allow_origins=["*"], # Use specific domains in production
|
| 15 |
+
allow_credentials=True,
|
| 16 |
+
allow_methods=["*"],
|
| 17 |
+
allow_headers=["*"],
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# ---- COG Tiler ----
|
| 21 |
+
cog = TilerFactory()
|
| 22 |
+
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"])
|
| 23 |
+
|
| 24 |
+
# ---- STAC Tiler ----
|
| 25 |
+
stac = STACTilerFactory()
|
| 26 |
+
app.include_router(stac.router, prefix="/stac", tags=["STAC Items"])
|
| 27 |
+
|
| 28 |
+
# ---- MosaicJSON Tiler ----
|
| 29 |
+
mosaic = MosaicTilerFactory()
|
| 30 |
+
app.include_router(mosaic.router, prefix="/mosaic", tags=["MosaicJSON"])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
# (Optional) Add a root endpoint
|
| 34 |
+
@app.get("/")
|
| 35 |
+
def read_index():
|
| 36 |
+
return {"message": "Welcome to TiTiler with COG, STAC, and Mosaic support"}
|