I've been trying to build a flask application which uses dynamic html files. My application uses the flask_app2.py to call two functions in parser.py and transitions.py. The application basically presents a branching story based on an option presented in each page. Which page should be loaded next is sent as a POST request which is then passed to parser.py and transitions.py to generate a a new html file. I'm using a single html file page.html and which keeps changing based on the option selected. However only a static version of this file is loaded when the reload button is pressed on the application page on the pythonanywhere site which results in the same page being shown no matter the button being pressed. I was wondering if anyone could tell me if there's something I could do so that the template html file dynamically changes? Below is the method in my flask file used to generate the new file. make_option_files and make_file are imported from other python files and used to change the contents of page.html.
def next(): if request.method == 'POST': form = request.form['option'] # Page for the pronunciation evaluation. if(form == "PronEval"): return render_template('PronEval.html') # Page for inteligibility remediation information. elif(form == "Info"): return render_template('Info.html') else: make_option_files(form) make_file(form) return render_template('page.html')
The structure of my directory is given below.
├─ AROWF-recently.txt ├── __init__.py ├── _config.yml ├── cmudict-en-us.dict ├── flask_app2.py ├── initial.js ├── jsgf_file_parser.py ├── parser.py ├── parser.pyc ├── sphinx4-5prealpha-src.zip ├── static │ ├── css │ │ └── materialize.min.css │ └── js │ ├── audioRecorder.js │ ├── audioRecorderWorker.js │ ├── callbackManager.js │ ├── materialize.min.js │ ├── pocketsphinx.js │ ├── recognizer.js │ └── recorder.js ├── templates │ ├── Info.html │ ├── PronEval.html │ ├── page-options.txt │ ├── page.html │ └── page.txt ├── transitions.py └── transitions.pyc