Your first full-stack app: a page that saves beats to your own Python server.
This app has two halves. The frontend (index.html, style.css, app.js) runs in the browser. The backend (server.py) is your Python, and it keeps the data, just like the Beat Server from Unit 11.
In server.py, when request["action"] is "save", store the beat: store[request["name"]] = request["beat"] and return {"ok": True}.
For any other action, return {"ok": False, "error": "unknown action"}. store is a dictionary Studio saves for you, so it's still there after a reload.
💡 Who uses this? This is full-stack development: a frontend in the browser talking to a backend server that keeps the data. Every app with an account — music, games, school — works this way.
index.html is what's on the page, style.css is how it looks, app.js is what it does (the frontend), and server.py is your Python backend. It keeps running between requests, and anything in the store dictionary is saved even after a reload.
rb.play("kick")Play one drum right now. rb.play("snare", 2) plays two quick hits.rb.playBeat({ kick: [1, 5], snare: [3, 7] })Loop a whole beat, like the course's drum commands. [3, 2] means beat 3 with 2 hits. Add a tempo: rb.playBeat(beat, 120).rb.stop()Stop the beat.await rb.server({ action: "save" })Send a request to your server.py's handle(request) and wait for its answer.rb.saveBeat({ kick: [1, 5] })Open a beat in RockBlocks, in a new tab.rb.msPerBeat(120)How many milliseconds one beat lasts at that tempo — handy for setInterval.Drums: crash, ride, openhat, hihat, hightom, tom, lowtom, rimshot, snare, kick
console.log() and your server's print() show up here.