Upload files to "backend"
This commit is contained in:
parent
7779eb279b
commit
1ba1339e73
3 changed files with 93 additions and 0 deletions
BIN
backend/__init__.py
Normal file
BIN
backend/__init__.py
Normal file
Binary file not shown.
11
backend/config.py
Normal file
11
backend/config.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent
|
||||||
|
DATA_DIR = BASE_DIR / "data"
|
||||||
|
UPLOADS_DIR = DATA_DIR / "uploads"
|
||||||
|
EPT_DIR = DATA_DIR / "ept" # était POTREE_DIR
|
||||||
|
|
||||||
|
UPLOADS_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
EPT_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
SUPPORTED_FORMATS = [".las", ".laz", ".ply", ".xyz", ".pts"]
|
||||||
82
backend/main.py
Normal file
82
backend/main.py
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||||
|
from config import EPT_DIR
|
||||||
|
from routes import upload, viewer, admin
|
||||||
|
from utils.disk import get_disk_usage, get_entwine_path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
ENTWINE_PATH = get_entwine_path()
|
||||||
|
|
||||||
|
app = FastAPI(title="PointCloud Backend")
|
||||||
|
app.mount("/ept_data", StaticFiles(directory=str(EPT_DIR)), name="ept_data")
|
||||||
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||||
|
|
||||||
|
app.include_router(upload.router)
|
||||||
|
app.include_router(viewer.router)
|
||||||
|
app.include_router(admin.router)
|
||||||
|
|
||||||
|
@app.get("/api")
|
||||||
|
def home():
|
||||||
|
return RedirectResponse(url="/docs")
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"entwine_available": ENTWINE_PATH is not None,
|
||||||
|
"entwine_path": ENTWINE_PATH,
|
||||||
|
"disk_free_gb": get_disk_usage(),
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_pdal_info() -> dict:
|
||||||
|
"""Retourne version et path de pdal via subprocess."""
|
||||||
|
info = {"path": None, "version": None}
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
["which", "pdal"],
|
||||||
|
capture_output=True, text=True, check=False
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
info["path"] = result.stdout.strip()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
["pdal", "--version"],
|
||||||
|
capture_output=True, text=True, check=False
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
# Sortie : "---\npdal 2.10.0 (git-version: 22e6b2)\n---"
|
||||||
|
lines = [l.strip() for l in result.stdout.strip().splitlines()
|
||||||
|
if l.strip() and not l.startswith("-")]
|
||||||
|
if lines:
|
||||||
|
info["version"] = lines[0]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/", response_class=HTMLResponse)
|
||||||
|
def home():
|
||||||
|
entwine_path = get_entwine_path()
|
||||||
|
pdal = get_pdal_info()
|
||||||
|
|
||||||
|
return f"""
|
||||||
|
<h2>Backend PointCloud OK ✅</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/docs">/docs</a> — Documentation API</li>
|
||||||
|
<li><a href="/health">/health</a> — État du service</li>
|
||||||
|
<li><a href="/list">/list</a> — Liste des nuages</li>
|
||||||
|
</ul>
|
||||||
|
<h3>Configuration</h3>
|
||||||
|
<ul>
|
||||||
|
<li>entwine : {"✅ " + entwine_path if entwine_path else "❌ Non trouvé"}</li>
|
||||||
|
<li>pdal path : {"✅ " + pdal["path"] if pdal["path"] else "❌ Non trouvé"}</li>
|
||||||
|
<li>pdal version : {pdal["version"] if pdal["version"] else "❌ Inconnue"}</li>
|
||||||
|
<li>Espace disque : {get_disk_usage()} GB libres</li>
|
||||||
|
</ul>
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue