Comparative flask noob here, with what might be a basic and silly question! I'm doing well with fairly simple Flask applications, e.g. of the type where we have n inputs: (Input_1,Input_2,....,Input_n), which our Python back-end grabs from our web form via request.form[ ] and feeds into some algorithm (Process_A), the outputs of which (Output_1.......Output_m) are displayed on the same web page via render_template('template.html',.......) I want to do something a little more complex. To summarize:
- Enter Input_1 and Input_2 in html form
- Send to Python code using request.form
- In Python back-end, apply Operation A to inputs to generate Output 1
- Send Output 1 back to the html front-end using render_template and display it
- Have a new form field appear, in which the user can enter Input_3
- Input_3, plus any (or all, or none) of Inputs 1 and 2 and Output 1 sent to Python via request.form
- Operation B takes these and produces further outputs, which are then sent back to the front-end. etc etc etc.
In essence, I want a form that performs calculations in stages, allowing the user to base subsequent inputs on the results of earlier operations. This is obviously super easy in Python with the console or data files or whatever - it's implementing it as an online calculator app that I'm stuck on. Particular questions:
- Do I need a new flask route for each subsequent passing back-and-forth of data?
- What should the arguments of these route definitions be?
- Do previous input definitions persist through the single piece of Python code? i.e. if Inputs 1 and 2 and Output 1 are to be arguments for Operation B, do they need to be re-requested in a new route function, or can they simply be used as is?
- How do I handle the 'staged reveal' of the form at the html end?
Any and all ideas warmly appreciated! Cheers!