Utilities to run and manage a FastAPI/uvicorn server
Project description
To publish:
uv run python -m build
uv run twine upload dist/*
To install:
uv add psServerWrapper
To use:
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:
python my_server.py --port 8000 --label dev --dt 1000 --debug false
CLI Arguments
--port: Port to bind to. Use0to 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
psserverwrapper-1.0.2.tar.gz
(3.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file psserverwrapper-1.0.2.tar.gz.
File metadata
- Download URL: psserverwrapper-1.0.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
accaf1eee4ade22bdd855060a775707becf7ea6239233411cc3b1350836be60e
|
|
| MD5 |
82b259aa26bd2e54f3b1e5e2cf580baa
|
|
| BLAKE2b-256 |
6c7d74384d9bde990894ace3e98ee8da1b07e5348488f55bc33bc57bcf9fafbe
|
File details
Details for the file psserverwrapper-1.0.2-py3-none-any.whl.
File metadata
- Download URL: psserverwrapper-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da2790a3f0b0d48ffe622b37a8bed3e6d4b0a07a6ebd8e31760a5f825a3f877d
|
|
| MD5 |
d751c981d8a164e6f38ff0d4312f2e88
|
|
| BLAKE2b-256 |
96a7a5d54e8627b2cd1078e4a098e474d03bd39b84f9393f4c794ccf35fde878
|