diff --git a/subgen.py b/subgen.py index 5bb9dc5..4954395 100644 --- a/subgen.py +++ b/subgen.py @@ -212,29 +212,36 @@ def form_get(): html_content += "
" for var_name, var_info in env_variables.items(): - # Use the value from the environment file if it exists, otherwise use the default - value = env_values.get(var_name, str(var_info['default'])) + # First, check if the variable is set in the OS environment + os_value = os.getenv(var_name) + # If not, use the value from the .env file + if os_value is None: + os_value = env_values.get(var_name, '') + # Convert the value to a boolean if necessary + value_bool = convert_to_bool(os_value) if isinstance(var_info['default'], bool) else os_value + # Generate the HTML content html_content += f"
{var_name}: {var_info['description']} (default: {var_info['default']})
" if var_name == "TRANSCRIBE_OR_TRANSLATE": - # Add a dropdown for TRANSCRIBE_OR_TRANSLATE with options 'Transcribe' and 'Translate' - selected_value = value if value in ['transcribe', 'translate'] else var_info['default'] - html_content += f"
" - elif isinstance(var_info['default'], bool): - # Convert the value to a boolean - value_bool = value.lower() == 'true' - # Determine the selected value based on the current value or the default value - selected_value = value_bool if value in ['True', 'False'] else var_info['default'] + selected_value = value_bool if value_bool in ['transcribe', 'translate'] else var_info['default'] html_content += f"
" + elif isinstance(var_info['default'], bool): + if os.getenv(var_name): + env_value = os.getenv(var_name) + elif env_values.get(var_name): + env_value = env_values.get(var_name) + else: + env_value = var_info['default'] + html_content += f"
" else: - html_content += f"
" + html_content += f"" - html_content += "
" + html_content += "
" return html_content