[Python] Pyscript terminal worker not executing past input()

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to add a python terminal onto a website using pyscript to run programs I've written using

    <script type="mpy" terminal worker src="subrepo/folder/program.py"></script>


    The terminal does appear, and it does run the first part of the code, put after the first input, it doesn't run.

    This is the code I'm trying to run in the terminal.

    #importing fuctions
    from functionsource1 import function1
    from functionsource2 import function2
    #giving user choice between which fuction to run
    choice = int(input("Choose to function1 or function2. Enter 1 to function1. Enter 2 to function2. "))
    if choice == 1:
    print("debug test")
    function1()
    elif choice == 2:
    print("debug test")
    function2()
    else:
    print("ERROR")


    After the code takes the input, nothing else runs, including the debug prints. I don't know what's wrong.

    For clarification, here's the full html file.

    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Portfolio</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@pyscript/core/dist/core.css">
    <script type="module" src="https://cdn.jsdelivr.net/npm/@pyscript/core/dist/core.js"></script>
    <mpy-config>
    [files]
    "./subrepo/folder/function1.py" = "function1.py"
    "./subrepo/folder/function2.py" = "function2.py"
    </mpy-config>
    </head>
    <body>
    <h1>Portfolio</h1>
    <p>
    My name is ---. I'll be putting any work I've done here for the time being. I'll update the site when I have something worthwhile to put here.
    </p>
    <script type="mpy" terminal worker src="subrepo/folder/program.py"></script>
    </body>
    </html>


    I'm working on a github codespace, if that affects anything.

    Continue reading...

Compartilhe esta Página