Authentication FastAPI with Keycloak

First you need to create a realm and client, and get the client id and secret. Go to Keycloak configuration problems and solutions to see how to setup at Keycloak Admin Panel. 1 Install dependencies pip install python-jose[cryptography]>=3.3.0 pip install cryptography>=3.4.0 pip install PyJWT==2.10.1 Setu…

Simulate streaming API with FastAPI

206 , , Leave a Comment
The server code import asyncio import uvicorn from fastapi import FastAPI from fastapi.responses import StreamingResponse app = FastAPI() async def fake_text_streaming(): for i in range(1000): yield b"Fake text #" + str(i).encode() + b"\n" await asyncio.sleep(1) @app.post("/") @app…