Hi All, i'm very new to flask and couldn't find an existing answer to my problem. Essentially I am trying to configure a flask website which would support the follow flow : 1) load of the default home website with menu in English. the default menu would have a 'choose language' section allowing a user to choose between English and Spanish (radio buttons) 2) upon ticking one of the radio buttons I would like the menu to change displaying all the functionalities (tick boxes with names ) in the selected language
3) the website also have a submit button which executes the underlying python nlp scripts and returns the results as a html which is then displayed to user
So far I am able to achieve 1 and 3 , but I don't know how to go about having this intermediary step 2 as I have already assign the 'POST' action to step 3 (results) bit. I am pasting below a reduced version of my code - would anyone be able to suggest a solution or point me to an example ? Many thanks
from flask import Flask, request
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route("/", methods=["GET", "POST"])
def my_page():
##this is triggered by button click and returns the final results in html format
if request.method == "POST":
return '<html><body><b>Results</b></body></html>'
#this part is the initial menu where I would like to add an action on selection of radio buttons
## which would result in the whole menu appearing in Spanish
return """<html><body>
<form method="post" action=".">
<b><font size="5">Choose language : </font></b>
<input type="radio" name="options" id="option1" value="option1"> English </input>
<input type="radio" name="options" id="option2" value="option2"> Spanish </input><br>
<hr>
<b><font size="5">Choose types of data to extract :</font></b><br/>
<input name="PERSON" type="checkbox" /> Persons
<input name="NORP" type="checkbox" /> Groups
<p><button onclick="submit" value="Run">Run </button></p>
</form></body></html>"""
[edit by admin: formatting]