HELLO WORLD
PyScript allows you to run Python code directly in your web browser without any server-side processing.
Key Features:
- Zero Server Setup: Python runs entirely in the browser using WebAssembly
- Standard Library Access: Use familiar Python modules like datetime, sys, and more
- Simple Integration: Add Python with just a tag
- External Scripts: Load Python code from files using the src attribute
- Console Output: View results in the browser console or write to the DOM
The Examples:
- Example 1: Classic "Hello World" - The simplest PyScript program
- Example 2: Current date/time - Demonstrates external Python scripts and datetime module
- Example 3: Fibonacci sequence - Shows algorithmic computation and list comprehension
- Example 4: Snake traversal - Matrix manipulation and DOM manipulation from Python
Getting Started:
The basic pattern for running Python in the browser is simple:
<script type="py">
print("Hello from Python!")
</script>
<!-- Or load from a file -->
<script type="py" src="/path/to/script.py"></script> Click the "π₯οΈ Open Console" button above to see the output of these Python scripts!