Metadata-Version: 2.4
Name: psServerWrapper
Version: 1.0.2
Summary: Utilities to run and manage a FastAPI/uvicorn server
Author: Anders Schou Simonsen
License-Expression: MIT
Requires-Python: >=3.14
Description-Content-Type: text/markdown
Requires-Dist: fastapi>=0.136.3
Requires-Dist: uvicorn>=0.48.0

To publish:

```bash
uv run python -m build
uv run twine upload dist/*
```

To install:

```bash
uv add psServerWrapper
```

To use:

```python
import uvicorn
import psServerWrapper
from fastapi import FastAPI, Request

app = FastAPI()

@app.post("/myEndpoint")
async def myEndpoint(request: Request):
    print("myEndpoint")
    res = {"success": True, "message": "Hi there"}
    return res


server: uvicorn.Server | None = None
psServerWrapper.register_shutdown_endpoint(app, lambda: server)
if __name__ == "__main__":
    def set_server(s: uvicorn.Server) -> None:
        global server
        server = s
    psServerWrapper.run(app, set_server)
```

Run your script with optional arguments:

```bash
python my_server.py --port 8000 --label dev --dt 1000 --debug false
```

## CLI Arguments

- `--port`: Port to bind to. Use `0` to auto-select a free port.
- `--label`: Label included in the status filename.
- `--dt`: Status write interval in milliseconds.
- `--tShutdown`: If no requests are being made to the api for tShutdown[ms] the server will shut down
- `--debug`: Enables uvicorn reload behavior intended for local development.
