Skip to main content

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. 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.

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psserverwrapper-1.0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for psserverwrapper-1.0.2.tar.gz
Algorithm Hash digest
SHA256 accaf1eee4ade22bdd855060a775707becf7ea6239233411cc3b1350836be60e
MD5 82b259aa26bd2e54f3b1e5e2cf580baa
BLAKE2b-256 6c7d74384d9bde990894ace3e98ee8da1b07e5348488f55bc33bc57bcf9fafbe

See more details on using hashes here.

File details

Details for the file psserverwrapper-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for psserverwrapper-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 da2790a3f0b0d48ffe622b37a8bed3e6d4b0a07a6ebd8e31760a5f825a3f877d
MD5 d751c981d8a164e6f38ff0d4312f2e88
BLAKE2b-256 96a7a5d54e8627b2cd1078e4a098e474d03bd39b84f9393f4c794ccf35fde878

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page