S
S
sortfact3332021-06-12 21:11:29
Python
sortfact333, 2021-06-12 21:11:29

How to pass object from JS to eel? Or does eel only support string?

How to pass object from js to eel?
I am trying to export the result of js code.
Sample code from three.js
js

//TEXT
  let exporter_stl = new STLExporter();
    function exportASCII_stl() {
    const result = exporter_stl.parse( scene );
    console.log(result)
    let res = await eel.test_link(result,'stl')();
    }
  //Binary
    function exportBinary_stl() {
    const result = exporter_stl.parse( scene, { binary: true } );
    console.log(result)
    eel(result,'stl');
    let res = await eel.test_link(result,'stl')();
    }
  setTimeout(exportBinary_stl, 3000);

python
@eel.expose
  def test_link(content,format):
    print(content)
    file = open('test.'+format, 'w+')
    file.write(content)
    file.close()

But the problem is that exportBinary_stl returns me an empty {}
And in the console itself, it returns

js
60bd7defa3c42471572282.png
python
60bd7df04170e838321827.png

typeof showed that the data type that I want to pass is called object

For comparison, exportASCII_stl returns everything correctly in both consoles.
typeof showed that it is a string

js
60bd7df101de9815327132.png
python
60bd7df1b9f7c824485812.png

I don't understand how I can pass the Binary code.
When I open it in a text editor, I get an unidentified code.
When I tried to generate a link and follow it in the browser, the file downloaded immediately. without being able to see its code.
I waited for the entire code to load, but I still get empty parentheses.
Has anyone passed the Binary code before. Object or Image.
Or does eel only support sring or number?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question