Err_connection_timed_out with pyscript

As title mentioned, i write a simple html file based on pyscript. On my laptop, it works fast and excellent, but when i send this html file to my friends’ laptop without any related python env, it will always stay in loading condition for long time and can’t enter successfully, when i check it via DevTools, it shows this error, like that (my friend’s page):


So how can i solve it, besides i’m from CHN, is it associated with GFW?

This is my code:

<!DOCTYPE html>
<html lang="en">
    <head>
      <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
        <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
      <py-env>
        - numpy
        - matplotlib
      </py-env>
      <style>
        span{
        color: blue;
        }
      </style>
    </head>

    <body style="margin: 25px 75px 25px 75px;">
    <div class="p-5 text-center bg-light">
      <p>Quick Draw by<a href="https://github.com/ELongking"> <span>Longking</span> </a></p>
      <p><a href="https://github.com/pyscript/pyscript"><span>PyScript</span></a> is a very new framework, it needs a few seconds to load...</p>
      <h3>If you want to use it again, you need to refresh the page</h3>
    </div>

    <div class="container1" id=prepare">
    <p>Please enter your equation which is need to be drawn</p>
    <input id="eq" type="text" style="width:300px" placeholder="y=2*x+sqrt(x) or z=x**2+y">
    <br>
    <p>Set the range of x coordinate</p>
    <input id="ra" type="text" style="width:200px" placeholder="-5,5 or -5,5;-5,5">
    <br>

    <p>Save or not</p>
    <input id="save" type="text" style="width:100px" placeholder="yes or no">
    <br>
    <button class="button" style="background-color: #00C0CB" type="button" id="file_select">Button -> Save directory</button>

    <br>
    </div>
    <br>
    <div class="container2" id="test-plot">
    <button id="but" style="margin-top: 10px;margin-bottom: 10px;background-color: #FFC0CB;" type="button" pys-onClick="main">
  Button -> Generate</button>
    </div>
    <py-script>
from numpy import *
from matplotlib import pyplot as plt, style as sty
import asyncio
from js import console, document, window, Blob
from pyodide import create_proxy, to_js

# main

    </py-script>
    </div>
  </body>
</html>

Yes, PyScript behind the scenes runs code to fetch Pyodide. I suspect that is the line that is failing. Is your friend loading from offline or a file URL?

Ask your friend to show the network tab, to find what is the URL that is failing.

If CHN and GFW mean China and the Great Firewall, then maybe the CDN for PyScript is being blocked within China. I am an Alibaba Cloud MVP, and I know that blocking is a real possibility. In that case package the PyScript files for local serving. The <py-config> tag supports specifying the PyScrypt origin.

However, this could be just a transient error and retrying (refresh the page) will solve the problem. I see a similar problem while developing. I wrote an article that shows how to catch these problems and display an alert box.