Features for classic MPA web dev

Probably belatedly, when perusing the docs, I recently stumbled upon the ‘route’ decorator, the ‘FormReponse ‘ function and the fact that the ‘HttpRequest.form_params’ attr is a dict (oh my, I’ve previously gone through writing a parser to extract data from a form data media object – an “interesting” exercise – and even more fun, manually packing/unpacking HTML form data into/from a custom blob). I’m super excited about this as it takes Anvil one step further towards not exclusively being a great platform for SPAs, but also a viable platform for (Jinja2-powered) Django-ish web dev (and interesting SPA/MPA Python/JS hybrids – love it!). May the Force be with the Anvil team!

Anyway, before I throw myself at these (new, I guess) features, I wonder if anybody knows where I can find additional info and/or examples re ‘FormReponse ‘ and ‘HttpRequest.form_params’? From the sparse docs usage seems straight forward, but if some examples could make me hit the ground running… Apologies if I’ve overlooking such resources.

Thx.

The route decorator is already usable. It’s incomplete, I imagine more features will come up in the more or less near future, but it’s usable.

An app can be:

  • SPA, where the app loads once and all the forms have the same URL (with the possible exception of the hash, the part of the URL invisible to the search engines)
  • MPA, where a new template is rendered to each URL
  • hybrid, where the app loads once and shows the form that matches the URL, and the URL keeps changing to match the form as the user navigates in the app

I like this third option, because the app is fast (it only loads once at startup) and the power of the Anvil forms is fully available. You can see here my first experiment playing with it.

1 Like

Thx. Yep, the ‘route’ decorator is fairly well-documented, and I’ve also use it to create a Flask-like app. We totally agree on the virtues of being able to write SPAs as well as MPAs.

However, as per my post, I’m after additional info re ‘FormReponse ‘ and ‘HttpRequest.form_params’… Any experience with those?