question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ideas for automatically fetching files on the web

See original GitHub issue

Thanks to Pyxel’s new utility script, an html file for Pyxel is very simplified like this.

Another thing I would like to achieve is automatic fetching of files. It seems that Emscripten can’t mount real file system directly, but it may be realized virtually if I can insert some hook script for each load function in Pyxel.

With the feature, I would like shorten this script from

<body>
    <div id="loading">Loading...</div>
    <pyxel-asset name="assets/pyxel_logo_38x16.png"></pyxel-asset>
    <pyxel-run root="../../python/pyxel/examples" name="01_hello_pyxel.py"
        onstart="document.getElementById('loading').remove()"></pyxel-run>
</body>

to

<body>
    <div id="loading">Loading...</div>
    <pyxel-run root="../../python/pyxel/examples" name="01_hello_pyxel.py"
        onstart="document.getElementById('loading').remove()"></pyxel-run>
</body>

If anyone has the knowledge to implement this feature, I would appreciate any advice.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kitaocommented, Oct 11, 2022

Thank you for your comment.

I just searched for synchronous XMLHTTPRequest sample code which works, and copied it. https://github.com/kitao/pyxel/blob/main/wasm/pyxel.js#L292-L299

Regarding file system side, when I tried whether I can replace functions under pyodide.FS, it worked. So I wrapped open and stat functions to invoke XMLHTTPRequest when called. https://github.com/kitao/pyxel/blob/main/wasm/pyxel.js#L319-L330

Best, Takashi Kitao.

2022年10月6日(木) 17:34 Minsoo @.***>:

It is astonishing! When I tried synchronous XMLRequest for hooks, the browser blocked it since it is deprecated. But your approach works! I know this is a closed issue AND this is not much relevant to the pyxel, but can you tell me how did you make it work?

— Reply to this email directly, view it on GitHub https://github.com/kitao/pyxel/issues/416#issuecomment-1269586234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFFXEWIRH5HDSGBQTFSVVTWB2FJVANCNFSM6AAAAAAQPBZJZI . You are receiving this because you modified the open/close state.Message ID: @.***>

1reaction
kitaocommented, Oct 5, 2022

In 1.8.12. I added a hook function for Emscripten file system so that Pyxel can get necessary files automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetching data from the server - Learn web development | MDN
This article shows how to start working with Fetch to fetch data from the server.
Read more >
Web Publishing with Fetch - Fetch Softworks
Fetch will automatically pick the correct format, quickly upload entire folders, and detect stalls and network or server errors and automatically resume uploads ......
Read more >
Import data from the web - Microsoft Support
On the Import Data from Web worksheet, copy the URL, which is a Wikipedia page for the FIFA World Cup standings. Select Data...
Read more >
8 Surprising Ways You Can Import Data Into Microsoft Word
1. Import a Table From Microsoft Excel · 2. Import a Single Cell From Microsoft Excel · 3. Import a Graph or Chart...
Read more >
Dropbox.com
Dropbox brings everything—traditional files, cloud content, and web shortcuts—together in one place. Get 2 GB of cloud storage for free with Dropbox Basic....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found