Python
cloud
Published

March 15, 2023

PyScript (WebAssembly)

I used pyscript for the first time and created a web page that run some Python code.

So here is the script I run.

import random

n = 20
emojis = "🙂😊🙂😀😇😅😃😄😁😂😆😉😋😎🤗"

lines = ["".join(random.choices(emojis, k=n)) for index in range(n)]

print("\n".join(lines))
😅😇🙂🤗🙂😅🙂😎🙂😂😃😂🤗🙂😇😀😀🙂😇😇
😊😊😆😇🙂😅🙂😂😁😉😆😅😆😊🙂🙂🙂😅😋🙂
😀😂😋🙂😉😋🤗🙂😇😆😃😁😊😅😆😄😇😊😆😆
😉🙂😃😎😊🙂😇😅😋😎😉😆😇😃🙂😁😆🙂🤗😃
😄😁🙂😇😅😋😋😎🙂😀🤗😁😇🤗😂😇😄🤗😋😅
🙂😋😂😇😁😃🙂😃😊🙂🙂🙂😀😂🤗😎😂😀😋😂
🤗🙂😎😄😃😎🤗🙂🙂😆😊😋😊🙂😁😅😅😅😎😁
😎😎😄😅😅😀🙂😀😅😁🙂😋😁😋😃😂😉🙂🤗😅
😇😂😁🤗😊🙂😀😄😂😀😅😁😄😄🙂😀😇😄😇😎
😎😋😆😇😇😎😀🙂😅😎😎😃😎😋😀😄🤗🙂😄😋
😋😅😊😊😇😆🙂😁😄😊😎😋😂😋😇🙂😉😇😃😉
😁😄😀😄😉😁😃😀🙂🤗😃😆😎🤗😄😎😎😅😂😄
🤗🤗🙂😎😋😅😂😆😄🙂😀😎😇😀😆🙂😋🙂😅😃
😋😄😋😇😉🙂😎😎🙂🙂😎😆😆😂😅🙂😅😁😋😃
😃😂😁😆😎😆😋😅😃😇😂😃🤗🙂😊😉😅🙂😇😅
😋😁😋🙂😋😁😉😊🤗😁😅😂🙂🙂😄😂😎😀😁😂
😊🙂😄😁😊🙂😃🙂🤗😁🙂😇😂😆😀🤗🙂😃🙂😊
😂😆😁😆😇🙂🙂😁😊😃😅😇🙂😅😊😃😉😀😉😅
😇😀😎😎😂😋😎😁😁😀😊😎😃🙂🤗😋😉😂😎😋
😆😎😇😉😂😎😀😀😋😀😅😃😉😎😃😇😎😎🙂😋

Here is the full html page that uses pyscript.

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <title>Happy DSS Hacking</title>
        <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
        <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>

    <body>
        <py-script>
            import random

            n = 100
            emojis = "🙂😊🙂😀😇😅😃😄😁😂😆😉😋😎🤗"

            lines = ["".join(random.choices(emojis, k=n)) for index in range(n)]

            print("\n".join(lines))
        </py-script>
    </body>

</html>