Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from layout import init_session_state, apply_theme | |
| from code_editor import render_code_editor | |
| from chatbot import render_chatbot | |
| # Page Setup | |
| st.set_page_config(page_title="Pro Code Playground", page_icon="💻", layout="wide") | |
| init_session_state() | |
| # Header | |
| st.title("Pro Code Playground") | |
| st.markdown("Write, execute & export multi-language snippets, with built‑in AI assistance.") | |
| # Language + Theme selection | |
| lang_col, spacer, theme_col = st.columns([3, 6, 1]) | |
| with lang_col: | |
| selected_lang = st.selectbox("Language", ["Python", "C", "C++", "Java", "JavaScript", "C#"], index=0) | |
| with theme_col: | |
| theme_choice = st.radio("Theme", options=["☀️", "🌙"], horizontal=True, label_visibility="collapsed") | |
| st.session_state.dark_mode = (theme_choice == "🌙") | |
| # Apply theme | |
| colors, ace_theme = apply_theme() | |
| # Layout: Editor + Chatbot | |
| gen, bot = st.columns((2, 1), gap="large") | |
| with gen: | |
| st.subheader("Editor") | |
| editor_key = f"editor_{selected_lang}" | |
| render_code_editor(selected_lang, ace_theme, editor_key) | |
| with bot: | |
| st.subheader("Code Assistant") | |
| render_chatbot( | |
| st.session_state.code, | |
| st.session_state.get("code_output", ""), | |
| st.session_state.get("error_output", "") | |
| ) | |
| # Footer | |
| st.markdown(""" | |
| <div style='text-align:center; margin-top:1rem; opacity:0.6;'> | |
| Built with ❤️ & Streamlit by Vaibhav | |
| </div> | |
| """, unsafe_allow_html=True) | |