A lightweight jokes website that runs Python in the browser via PyScript.
Jokes come from the excellent pyjokes package. Users can pick a category, rate jokes, view their local history, and see stats — all stored in the browser (no server needed).
- 🐍 Python in the browser with PyScript (no backend required)
- 🎭 Category picker:
auto(default),neutral,chuck,all - ⭐ Rate jokes (1–5), with persistent history and average rating
- 🔊 Optional text‑to‑speech using the browser’s Speech Synthesis API
- 🎨 Clean UI that mixes Bootstrap 5 components and Tailwind utilities (prefixed with
tw-to avoid conflicts)
- HTML + CSS
- Bootstrap 5 (layout/components)
- Tailwind CSS via CDN with
tw-prefix (utility classes) - PyScript to run Python (
pyjokes) directly in the browser
.
├── index.html # Main page (loads PyScript & CDNs; links style.css and jokes.py)
├── style.css # Custom styles for dark UI and layout
├── jokes.py # Python logic: jokes, history, ratings, stats, voice hooks
├── .gitignore # Common ignores for editors/builds
├── LICENSE # MIT license
└── README.md # You are here
- Clone or download this repo.
- Open
index.htmlin a modern browser (Chrome/Edge/Firefox).Internet is required on first load because PyScript, Bootstrap, and Tailwind are loaded from CDNs.
- Click “Tell me a joke” and have fun!
Tip: You can also host this as a static site (e.g., GitHub Pages). See Deploy below.
- Name (optional): enter your name for a friendly greeting.
- Category: pick
neutral,chuck, orall, or leave Auto. - Buttons:
- Tell me a joke – fetches a new joke.
- Repeat last – speaks/shows the previous joke again.
- Show history – lists jokes from this browser (persisted).
- Show stats – shows total count and average rating.
- Clear history – wipes jokes & ratings from local storage.
- Voice On/Off – toggles text‑to‑speech.
- Rate (1–5): records your rating and updates the stats.
All state is stored in localStorage on your device/browser.
- Styling: Use Bootstrap + Tailwind utilities (
tw-*) and tweakstyle.cssfor colors and layout. - Default category: Change the default
<option>inindex.htmlor the category handling injokes.py. - Voice behavior: The helper
speak()function inindex.htmlcontrols rate/pitch/volume—adjust as you like. - Categories:
jokes.pyusespyjokescategories. Extend or change theCATEGORIESlist if needed.
- The main joke box uses
aria-live="polite"so screen readers announce new jokes. - Buttons have clear labels; rating buttons are simple numeric controls.
MIT © 2025 Priyanshu Thakur