3DGS / main.py
BenjaminBleske's picture
Upload 4 files
1e917f6
Raw History Blame Contribute Delete
1.15 kB
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
import os
app = FastAPI()
# Allow CORS so that the GitHub Pages site can fetch the file
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Für Entwicklung alles erlauben, später auf GitHub Pages anpassen
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
DATA_DIR = "data"
@app.get("/")
def read_root():
return {"message": "Gaussian Splat FastAPI Server running."}
@app.get("/model.ply")
def get_model_ply():
file_path = os.path.join(DATA_DIR, "model.ply")
if os.path.exists(file_path):
return FileResponse(file_path, media_type="application/octet-stream")
return {"error": f"Model file not found. Please place 'model.ply' in '{DATA_DIR}/'"}
@app.get("/model.splat")
def get_model_splat():
file_path = os.path.join(DATA_DIR, "model.splat")
if os.path.exists(file_path):
return FileResponse(file_path, media_type="application/octet-stream")
return {"error": f"Model file not found. Please place 'model.splat' in '{DATA_DIR}/'"}