server-thread

⚙️ Launch a WSGI or ASGI Application in a background thread with werkzeug or uvicorn

MIT License

Downloads
34.1K
Stars
6
Committers
1
server-thread - Support ASGI and WSGI Applications Latest Release

Published by banesullivan over 2 years ago

Version 0.2.0 adds support for ASGI applications so that server-thread can be used with ASGI micro-frameworks like FastAPI

Here is a minimal example with FastAPI:

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def root():
    return {"message": "Howdy!"}


server = ServerThread(app)
requests.get(f"http://{server.host}:{server.port}/").json()

See https://github.com/banesullivan/server-thread/discussions/3 for another example with FastAPI and tile serving