Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Last active September 18, 2022 20:12
Show Gist options
  • Save rsbohn/afc831d55d4a411c424bbb43cd87d9f6 to your computer and use it in GitHub Desktop.
Save rsbohn/afc831d55d4a411c424bbb43cd87d9f6 to your computer and use it in GitHub Desktop.
PyScript Demo for
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PyScript Alpha</title>
<link rel="icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- paths:
- pyscript/psboard.py
</py-env>
</head>
<body>
<div id="main">
<canvas width=640 height=64 id="display"></canvas>
<py-script>
#import psboard as board
board = {}
board.DISPLAY = document.getElementById("display")
board.main = document.getElementById("main")
board.DISPLAY.style.backgroundColor="#454"
board.main.style.marginLeft="2em"
board.main.style.marginRight="2em"
board.main.style.border="solid black 2px"
print(f"board.DISPLAY is {board.DISPLAY.width}x{board.DISPLAY.height}.")
</py-script>
</div>
<py-repl output="main">
display = board.DISPLAY
cx=display.getContext('2d')
cx.fillStyle="ivory"
for x in range(8,640,8):
cx.fillRect(x,0,2,8)
</py-repl>
</body>
</html>
@rsbohn
Copy link
Author

rsbohn commented Sep 18, 2022

Put this file on your Feather ESP32-S2 and soon you'll be running PyScript in your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment