What runs in the browser: asynchronous updates, client operations and their risks.
Lectures this week
- Application Frontends
- Asynchronous Updates
- Browser/Client Operations
- Client-Side Computations
- Security Implications
Key points, notes and past questions
Web Architecture, Protocols & Rendering
The HTTP request cycle, statelessness, rendering location and scaling vocabulary.
- The request cycle and HTTP methods
- DNS first: the name becomes an IP address.
- Then request, response (or error code), and display.
- GET returns headers and body; HEAD returns headers only.
- MVC is a software architecture pattern; IP addresses and routes data.
- Statelessness and cookies
- Stateless: the server keeps no client state between requests.
- A cookie is stored by the browser and sent back with each request.
- Cookies let sites recognise users and remember login, language, location.
- Flask reads cookies with
request.cookiesand sets them withset_cookie.
- Server-side and client-side rendering
- SSR: the server sends complete HTML (Flask + Jinja2).
- CSR: the server sends a skeleton and JS; the browser builds the DOM.
- SSR: faster first load, better SEO.
- CSR: less server rendering work, smoother partial updates.
- Cloud models and scaling
- IaaS: machines; PaaS: platform (bring code); SaaS: finished app.
- Scale up = bigger machine (RAM); scale out = more machines.
- ACID for financial transactions; BASE for social media scale.
- Redundancy = spares for failure; replication = copies of data/service.
Notes11 past questions in this topic
Frontend Web Technologies (HTML, CSS, JavaScript & DOM)
The browser side that Flask pages feed.
- Start here: HTML, CSS and JavaScript, from zero
- HTML = content and structure.
- CSS = how it looks; selectors choose elements.
- JavaScript = behaviour, in the browser.
- JSON = data between programs, not a page language.
- HTML structure, lists and linking scripts
- HTML = content, CSS = styling, JS = extra behaviour.
<ul>unordered,<ol>ordered,<dl>term/description.- External JS:
<script src="file.js"></script>. - A page works without JavaScript.
- Which CSS rule wins
- inline > #id > .class > tag.
- On a tie, the later rule wins.
- The order of names inside
class="..."does not matter.
- Attribute selectors
~== whole word in a space-separated list.*== substring anywhere.- Hyphens do not split words for
~=.
- :valid and :invalid
:valid/:invalidupdate live.- Empty and not required → valid.
- minlength counts typed characters only.
- maxlength stops typing at the limit.
- HTML5 validation attributes and JavaScript checks
- HTML5 checks run first and block the submit event.
- JS onsubmit checks = client-side validation.
- Checks in the Flask view = backend validation.
- Message wording follows the browser's language.
- JavaScript output: alert, console, document.write, innerHTML
- alert = dialog box.
- console.log / console.error = developer console.
- innerHTML / textContent = inside an element.
- document.write after load = replaces the page.
- JSON syntax and parsing
- Object keys in double quotes.
- Arrays hold values, not key: value pairs.
- Mixed types in an array are fine.
- Property access order decides output order.
- The DOM, live collections and AJAX
- DOM = programming interface + abstract tree of the page; it can change.
getElementsByTagNameis live;querySelectorAllis static.- AJAX = background request + partial update, no reload.
- AJAX gives a better experience with less data.