sanjay7178 commited on
Commit
2398853
·
1 Parent(s): aef9afa

feat: fix: preserve processing mode selection in UI with state management

Browse files
Files changed (2) hide show
  1. app.py +4 -2
  2. templates/index.html +2 -2
app.py CHANGED
@@ -58,23 +58,25 @@ def process_old_ssml_text(ssml_text):
58
  def index():
59
  processed_text = ""
60
  input_text = ""
 
61
 
62
  if request.method == 'POST':
63
  input_text = request.form.get('input_text', '')
64
  processed_text = process_ssml_text(input_text)
65
 
66
- return render_template('index.html', processed_text=processed_text, input_text=input_text)
67
 
68
  @app.route('/old', methods=['GET', 'POST'])
69
  def old_index():
70
  processed_text = ""
71
  input_text = ""
 
72
 
73
  if request.method == 'POST':
74
  input_text = request.form.get('input_text', '')
75
  processed_text = process_old_ssml_text(input_text)
76
 
77
- return render_template('index.html', processed_text=processed_text, input_text=input_text)
78
 
79
  if __name__ == '__main__':
80
  app.run(debug=True)
 
58
  def index():
59
  processed_text = ""
60
  input_text = ""
61
+ current_endpoint = "/"
62
 
63
  if request.method == 'POST':
64
  input_text = request.form.get('input_text', '')
65
  processed_text = process_ssml_text(input_text)
66
 
67
+ return render_template('index.html', processed_text=processed_text, input_text=input_text, current_endpoint=current_endpoint)
68
 
69
  @app.route('/old', methods=['GET', 'POST'])
70
  def old_index():
71
  processed_text = ""
72
  input_text = ""
73
+ current_endpoint = "/old"
74
 
75
  if request.method == 'POST':
76
  input_text = request.form.get('input_text', '')
77
  processed_text = process_old_ssml_text(input_text)
78
 
79
+ return render_template('index.html', processed_text=processed_text, input_text=input_text, current_endpoint=current_endpoint)
80
 
81
  if __name__ == '__main__':
82
  app.run(debug=True)
templates/index.html CHANGED
@@ -118,8 +118,8 @@
118
  <div class="endpoint-selector">
119
  <label for="endpoint">Processing Mode:</label>
120
  <select id="endpoint" name="endpoint">
121
- <option value="/" selected>New Format (textnorm)</option>
122
- <option value="/old">Old Format (DECIMAL/CURRENCY/DATE....)</option>
123
  </select>
124
  </div>
125
 
 
118
  <div class="endpoint-selector">
119
  <label for="endpoint">Processing Mode:</label>
120
  <select id="endpoint" name="endpoint">
121
+ <option value="/" {% if current_endpoint == "/" %}selected{% endif %}>New Format (textnorm)</option>
122
+ <option value="/old" {% if current_endpoint == "/old" %}selected{% endif %}>Old Format (DECIMAL/CURRENCY/DATE....)</option>
123
  </select>
124
  </div>
125