I’m writing an application with Flask and I’d like to generate different code for desktop and mobile browsers. IMHO it should be a good idea to keep the application code identical and push the problem of serving different content down the stack at the template level – so it essentially becomes a matter of writing two sets of templates for the two use cases and finding a way to choose the correct one to use at every single request.
I’m using the default Jinja2 template engine with Flask.
I should mention that I have no experience with Flask and I’m learning my way through it while I write code – I’m taking this as an exercise too 🙂
What mechanism would you use to address this problem and keep source code as clean as possible?
Replying to myself 🙂
I ended up using this solution:
so far it seems to work, and I just put “mobile templates” in an
m/subdirectory.