-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PyCon.net homepage for PyCon 2024 (#64)
* First pass. A real PyScript terminal, typing code, updated copy. * Outgoing links target=_blank * Fixed character bleeding. * Firefox on mobile fixes. * Minor Pythonic update. * Check on SAB. * Minor fixes.
- Loading branch information
Showing
4 changed files
with
155 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
Well done! You've found the source. | ||
If you're at PyCon 2024, email ntollervey <at> anaconda.com | ||
and (subject to availability) you can have some PyScript | ||
swag. :-) | ||
Now go build cool stuff with PyScript. | ||
""" | ||
import asyncio | ||
import random | ||
from pyscript import document | ||
|
||
|
||
# It's the same API as JS when using the document object! | ||
python_terminal = document.getElementById("python-terminal") | ||
|
||
|
||
async def type_it_in(code): | ||
""" | ||
Advanced AI to type code into the terminal. ;-) | ||
""" | ||
lines = code.split("\n") | ||
for line in lines: | ||
await asyncio.sleep(1) | ||
for char in line: | ||
wait = random.choice( | ||
[0.05, 0.07, 0.1, 0.15, 0.2, 0.3] | ||
) | ||
await asyncio.sleep(wait) | ||
python_terminal.terminal.write(char) | ||
python_terminal.process(line.strip()) | ||
|
||
|
||
# Web scale use of advanced AI. | ||
await type_it_in( | ||
'print("Hello, from PyScript!")\r\n' | ||
'# Your turn...' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */ | ||
/*! mini-coi - Andrea Giammarchi and contributors, licensed under MIT */ | ||
(({ document: d, navigator: { serviceWorker: s } }) => { | ||
if (d) { | ||
const { currentScript: c } = d; | ||
s.register(c.src, { scope: c.getAttribute('scope') || '.' }).then(r => { | ||
r.addEventListener('updatefound', () => location.reload()); | ||
if (r.active && !s.controller) location.reload(); | ||
}); | ||
} | ||
else { | ||
addEventListener('install', () => skipWaiting()); | ||
addEventListener('activate', e => e.waitUntil(clients.claim())); | ||
addEventListener('fetch', e => { | ||
const { request: r } = e; | ||
if (r.cache === 'only-if-cached' && r.mode !== 'same-origin') return; | ||
e.respondWith(fetch(r).then(r => { | ||
const { body, status, statusText } = r; | ||
if (!status || status > 399) return r; | ||
const h = new Headers(r.headers); | ||
h.set('Cross-Origin-Opener-Policy', 'same-origin'); | ||
h.set('Cross-Origin-Embedder-Policy', 'require-corp'); | ||
h.set('Cross-Origin-Resource-Policy', 'cross-origin'); | ||
return new Response(body, { status, statusText, headers: h }); | ||
})); | ||
}); | ||
} | ||
})(self); |