Spaces:
Sleeping
Sleeping
Download main.py from BenjaminBleske/3DGS: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/BenjaminBleske/3DGS/resolve/main/main.py
- Command line
-
hf download hf://spaces/BenjaminBleske/3DGS/main.py
-
curl -L -o main.py https://huggingface.co/spaces/BenjaminBleske/3DGS/resolve/main/main.py
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" | |
| def read_root(): | |
| return {"message": "Gaussian Splat FastAPI Server running."} | |
| 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}/'"} | |
| 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}/'"} | |