Skip to content

Commit a2414f6

Browse files
committed
Refactor code to handle privacy policy acceptance
1 parent 08ae83c commit a2414f6

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

script.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,13 @@ def main():
391391
execute_submitted = st.form_submit_button("Execute")
392392
if execute_submitted:
393393
# Execute the code.
394-
if st.session_state.compiler_mode in ["Offline", "Online","API"]:
395-
privacy_accepted = st.session_state.get(f'compiler_{st.session_state.compiler_mode.lower()}_privacy_accepted', False)
396-
397-
if privacy_accepted:
398-
st.session_state.output = general_utils.execute_code(st.session_state.compiler_mode)
399-
else:
400-
st.toast(f"You didn't accept the privacy policy for {st.session_state.compiler_mode} compiler.", icon="❌")
401-
logger.error(f"You didn't accept the privacy policy for {st.session_state.compiler_mode} compiler.")
394+
privacy_accepted = st.session_state.get(f'compiler_{st.session_state.compiler_mode.lower()}_privacy_accepted', False)
395+
396+
if privacy_accepted:
397+
st.session_state.output = general_utils.execute_code(st.session_state.compiler_mode)
398+
else:
399+
st.toast(f"You didn't accept the privacy policy for {st.session_state.compiler_mode} compiler.", icon="❌")
400+
logger.error(f"You didn't accept the privacy policy for {st.session_state.compiler_mode} compiler.")
402401

403402
# Show the privacy policy for compilers.
404403
handle_privacy_policy(st.session_state.compiler_mode)
@@ -436,12 +435,7 @@ def main():
436435
# Display the code output
437436
if st.session_state.output:
438437
st.markdown("### Output")
439-
#st.toast(f"Compiler mode selected '{st.session_state.compiler_mode}'", icon="✅")
440-
if (st.session_state.compiler_mode.lower() == "offline"):
441-
if "https://www.jdoodle.com/plugin" in st.session_state.output:
442-
pass
443-
else:
444-
st.code(st.session_state.output, language=st.session_state.code_language.lower())
438+
st.code(st.session_state.output, language=st.session_state.code_language.lower())
445439

446440
# Display the price of the generated code.
447441
if st.session_state.generated_code and st.session_state.display_cost:

0 commit comments

Comments
 (0)