-
I was wondering if I can solve my usecase with FastStream. I'm trying to have an endpoint which consumes the latest element from a stream and returns it as response. I have this from the FastAPI documentation but I dont know how to combine it, since right now they both exist concurrently. Also I cant comment out
from fastapi import FastAPI
from faststream.redis.fastapi import RedisRouter, Logger
from faststream.redis import StreamSub
from caminterface import Image
router = RedisRouter("redis://localhost:6379")
@router.subscriber(stream=StreamSub("Images"))
async def hello(m: Image, logger: Logger):
logger.info(m)
@router.get("/")
async def hello_http():
return "Hello, HTTP!"
app = FastAPI(lifespan=router.lifespan_context)
# app.include_router(router)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, port=5001, log_level="info") This is what I am looking for. @router.get("/image")
@router.subscriber(stream=StreamSub("Images"))
async def image_http(m: Image, logger: Logger):
# process the image do some conversions etc..
return FileResponse(m, media_type="image/png") Maybe FastStream is not meant to be used like that? Thx in advance. |
Beta Was this translation helpful? Give feedback.
Answered by
Lancetnik
Feb 19, 2024
Replies: 1 comment 5 replies
-
@4ydan sorry, it was a bug. I'll fix it with |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
4ydan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@4ydan sorry, it was a bug. I'll fix it with
0.4.3