i am trying to make a file streamer from telegram in flask
code i used
from flask import Response@app.route("/dl/<hash>", methods=["GET"])async def download(hash): body = yield_file() return Response( status=206 if range_header else 200, response=body, headers={"Content-Type": f"{mime_type}","Content-Range": f"bytes {from_bytes}-{until_bytes}/{file_size}","Content-Length": str(req_length),"Content-Disposition": f'{disposition}; filename="{file_name}"',"Accept-Ranges": "bytes", }, )where the yield_file() function i took from https://github.com/EverythingSuckz/TG-FileStreamBot/blob/3f7304fa023e373e873c05abe431aafd537020fe/WebStreamer/utils/custom_dl.py#L164
in the repo he used aiohttp web server and it works fine there
but in flask it gives the following error
127.0.0.1 - - [03/Aug/2023 22:21:06] "GET /dl/jRtYoKqEu6 HTTP/1.1" 500 -Error on request:Traceback (most recent call last): File "C:\Users\hp\AppData\Roaming\Python\Python310\site-packages\werkzeug\serving.py", line 364, in run_wsgi execute(self.server.app) File "C:\Users\hp\AppData\Roaming\Python\Python310\site-packages\werkzeug\serving.py", line 327, in execute for data in application_iter: File "C:\Users\hp\AppData\Roaming\Python\Python310\site-packages\werkzeug\wsgi.py", line 289, in __next__ return self._next() File "C:\Users\hp\AppData\Roaming\Python\Python310\site-packages\werkzeug\wrappers\response.py", line 32, in _iter_encoded for item in iterable:TypeError: 'async_generator' object is not iterablecan i know whats the problem here and how to fix that
Edit :
Maybe the problem is because of this https://github.com/pallets/werkzeug/blob/41b74e7a92685bc18b6a472bd10524bba20cb4a2/src/werkzeug/wrappers/response.py#L32
It is using for keyword instead of async for