Pyscript, download file to user device

I’m working on a pyscript project and in this project I use this code to write some binary data into a file:

with open(name, 'ab') as f:
    f.write(data)

And after that I need to download the created file into user’s device, that’s what I’m stuck with. How should I tell the browser to download this file? (I’ve googled and tested a bunch of solutions but none worked! It was like all the solutions were using deprecated libraries)