Simple FastAPI app that loads a scikit-learn pipeline from full_rockfall_pipeline.pkl and exposes a /predict endpoint.
Quick start
- Create a virtual environment and install dependencies:
python -m venv .venv; .\.venv\Scripts\Activate.ps1; pip install -r requirements.txt- Set an API key (optional) and run on port 8002 (default):
$env:API_KEY = "changeme"; python .\main.py- Example request (replace with your feature JSON):
Invoke-RestMethod -Method Post -Uri http://localhost:8002/predict -Headers @{"access_token"="changeme"} -Body (@{data=@{feature1=1; feature2=2}} | ConvertTo-Json)Notes
- Place
full_rockfall_pipeline.pklnext tomain.py. - Set
API_PORTto change the local port. Defaults to 8002 to avoid conflicts with other APIs.