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.1.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.1.tar.gz.
File metadata
- Download URL: psserverwrapper-1.0.1.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 |
b77dd0d37cb20ca6fccd908455e431681bfe4b24df004b5a69d310c1112c51ee
|
|
| MD5 |
5ff517468b4d8919931bb2dd7a9cf5cf
|
|
| BLAKE2b-256 |
a59b0511b9910e8c430694062f8cff8556d895944fa77e624ed24d46e7d79648
|
File details
Details for the file psserverwrapper-1.0.1-py3-none-any.whl.
File metadata
- Download URL: psserverwrapper-1.0.1-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 |
89e26e23ac147bcbf1073cde80508987ab203bd9136695b11f0e54462f1526c6
|
|
| MD5 |
4fb910384c1e96d64885d77eb01fcc0a
|
|
| BLAKE2b-256 |
20a46821666a70afba5af042bfb7cc030eea5f9840d25686ffdf6c6bdb289d99
|