PyScript not working as intended

I’m just testing out PyScript but whenever I open the html file as a live server, the page opens but it doesn’t show what it’s supposed to show. It only displays the python code as text on the webpage. Btw I cloned the repo and directly ran the server.

sir use as normal python script!! like don’t give any space before the python code.

ex:

<head>

    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />

    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>

</head>

<body>

    <py-script>

import random

num = random.randint(1,100)

print(f"The number is {num}")

for i in range(1,11):

print(f"{i} * {num} = {i*num}")

    </py-script>

</body>

Hello
So ur code works but when I try the todolist code from the github page, This is what I see:

- paths: - ./utils.py def add_task(*ags, **kws): # create a new dictionary representing the new task task = { "content": new_task_content.value, "done": False, "created_at": dt.now() } # add a new task to the list and tell it to use thecontentkey to show in the UI # and to use the keydone to sync the task status with a checkbox element in the UI myList.add(task) # clear the inputbox element used to create the new task new_task_content.clear() To Do List def on_keypress(e): if (e.code == "Enter"): add_task() def on_click(evt): add_task()

I tried this and worked:

<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> 
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
  • put the files in pyscript-main/pyscriptjs/examples/build folder.

  • open the page via http://localhost:8080/.

  • wait about 10s, for wasm loading…you can check it using F12(chrome) - Network

it seems that the npm install doesn’t work correctly, but it do run a web service. so after i pasted the correct js file, it worked.