@pyscript/core PyScript Next into nuxt/vue app integration problems #1838
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I dug a bit into pyodide and found a solution for point 7. file = open(file_path, "rb")
byte_buffer = file.read()
file.close()
blob = Blob.new([to_js(byte_buffer)], {type: "application/octet-stream"})
blob_url = URL.createObjectURL(blob)
sync.output({"blobUrl": blob_url}) On the javascript-end I can fetch the data which is probably a fetch from cache. Then use the binary data to provide a download or in my case i fetch it as text content: worker.sync.output = (data) => {
(async () => {
const blob = await fetch(data.blobUrl).then((r) => r.blob());
out.value = await blob.text();
})();
}; Seems a good approach, but I would still like to know if there is a better or more comfortable way. |
Beta Was this translation helpful? Give feedback.
-
lot of points but I can't really help much with your setup so point 1 and 2 will be skipped ... other points:
I hope some answer is helpful, feel free to ask more though. |
Beta Was this translation helpful? Give feedback.
-
yeah sounds about right.
I had to go through the same exercise as you and decided to maintain a library on top of polyscript. feel free to look at it for inspiration: https://bugzpodder.github.io/pysandbox/ |
Beta Was this translation helpful? Give feedback.
lot of points but I can't really help much with your setup so point 1 and 2 will be skipped ... other points:
<py-script>
both exists but it's mostly for backward compatibility and it warns if it contains some HTML tag. The recommended way to use PyScript is via<script type="py">
which would solve everything you are witnessing unless your vite/setup complains also there about unrecognized type ... which I don't know, but "this is the way"xworker.sync
as that's al unknown until you define it and it's hard to explain to TS because it could be either sync (worker) or async (main) ... if anyone is willing to help out there, please file a PR. That be…