Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,12 +10,12 @@ genai.configure(api_key="AIzaSyC7op0zN_EESTSFhXGtzHRYImp5nhvDz-c")
|
|
| 10 |
# Custom CSS for advanced styling
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
-
body {background-color: #
|
| 14 |
-
.main-title {text-align: center; font-size:
|
| 15 |
-
.sub-header {text-align: center; font-size:
|
| 16 |
-
.stTextArea textarea {background-color: #
|
| 17 |
-
.stButton button {background-color: #
|
| 18 |
-
.stDownloadButton button {background-color: #32CD32; color: white; font-size:
|
| 19 |
</style>
|
| 20 |
""", unsafe_allow_html=True)
|
| 21 |
|
|
@@ -25,17 +25,17 @@ def animated_text(text, speed=0.07):
|
|
| 25 |
displayed_text = ""
|
| 26 |
for letter in text:
|
| 27 |
displayed_text += letter
|
| 28 |
-
placeholder.markdown(f'<h1 class="main-title">{displayed_text}
|
| 29 |
time.sleep(speed)
|
| 30 |
|
| 31 |
# Animated Welcome Text
|
| 32 |
-
animated_text("Welcome to AI
|
| 33 |
|
| 34 |
# Streamlit Layout
|
| 35 |
-
st.markdown("<h2 class='sub-header'
|
| 36 |
|
| 37 |
# User Input for Buggy Code
|
| 38 |
-
buggy_code = st.text_area("π
|
| 39 |
|
| 40 |
# Function to debug code
|
| 41 |
def debug_code_with_gemini(code):
|
|
@@ -53,24 +53,24 @@ def get_suggestions_with_gemini(code):
|
|
| 53 |
|
| 54 |
# Processing user input
|
| 55 |
if buggy_code:
|
| 56 |
-
with st.spinner("
|
| 57 |
fixed_code = debug_code_with_gemini(buggy_code)
|
| 58 |
|
| 59 |
-
with st.spinner("
|
| 60 |
suggestions = get_suggestions_with_gemini(fixed_code)
|
| 61 |
|
| 62 |
# Display Debugged Code
|
| 63 |
-
st.markdown("<h2 class='sub-header'>β
|
| 64 |
st.code(fixed_code, language="python")
|
| 65 |
|
| 66 |
# Download button for Fixed Code
|
| 67 |
st.download_button(
|
| 68 |
-
label="π₯ Download
|
| 69 |
data=fixed_code,
|
| 70 |
-
file_name="
|
| 71 |
mime="text/plain"
|
| 72 |
)
|
| 73 |
|
| 74 |
# Display AI Suggestions
|
| 75 |
-
st.markdown("<h2 class='sub-header'>π‘ AI
|
| 76 |
st.write(suggestions)
|
|
|
|
| 10 |
# Custom CSS for advanced styling
|
| 11 |
st.markdown("""
|
| 12 |
<style>
|
| 13 |
+
body {background-color: #121212; color: #E0E0E0;}
|
| 14 |
+
.main-title {text-align: center; font-size: 45px; font-weight: bold; color: #00FFFF;}
|
| 15 |
+
.sub-header {text-align: center; font-size: 28px; font-weight: bold; color: #FFD700;}
|
| 16 |
+
.stTextArea textarea {background-color: #1E1E1E; color: #00FF7F; border-radius: 12px;}
|
| 17 |
+
.stButton button {background-color: #FF6347; color: white; font-size: 20px; border-radius: 12px;}
|
| 18 |
+
.stDownloadButton button {background-color: #32CD32; color: white; font-size: 20px; border-radius: 12px;}
|
| 19 |
</style>
|
| 20 |
""", unsafe_allow_html=True)
|
| 21 |
|
|
|
|
| 25 |
displayed_text = ""
|
| 26 |
for letter in text:
|
| 27 |
displayed_text += letter
|
| 28 |
+
placeholder.markdown(f'<h1 class="main-title">{displayed_text} β¨</h1>', unsafe_allow_html=True)
|
| 29 |
time.sleep(speed)
|
| 30 |
|
| 31 |
# Animated Welcome Text
|
| 32 |
+
animated_text("π Welcome to CodeFix Pro - AI Debug & Optimize! π‘")
|
| 33 |
|
| 34 |
# Streamlit Layout
|
| 35 |
+
st.markdown("<h2 class='sub-header'>π€ Smart AI-Powered Code Debugger & Enhancer</h2>", unsafe_allow_html=True)
|
| 36 |
|
| 37 |
# User Input for Buggy Code
|
| 38 |
+
buggy_code = st.text_area("π Enter your buggy code here:", height=250)
|
| 39 |
|
| 40 |
# Function to debug code
|
| 41 |
def debug_code_with_gemini(code):
|
|
|
|
| 53 |
|
| 54 |
# Processing user input
|
| 55 |
if buggy_code:
|
| 56 |
+
with st.spinner("π Analyzing and fixing your code... π οΈ"):
|
| 57 |
fixed_code = debug_code_with_gemini(buggy_code)
|
| 58 |
|
| 59 |
+
with st.spinner("β¨ Enhancing your code with best practices..."):
|
| 60 |
suggestions = get_suggestions_with_gemini(fixed_code)
|
| 61 |
|
| 62 |
# Display Debugged Code
|
| 63 |
+
st.markdown("<h2 class='sub-header'>β
Your Debugged Code:</h2>", unsafe_allow_html=True)
|
| 64 |
st.code(fixed_code, language="python")
|
| 65 |
|
| 66 |
# Download button for Fixed Code
|
| 67 |
st.download_button(
|
| 68 |
+
label="π₯ Download Corrected Code",
|
| 69 |
data=fixed_code,
|
| 70 |
+
file_name="corrected_code.py",
|
| 71 |
mime="text/plain"
|
| 72 |
)
|
| 73 |
|
| 74 |
# Display AI Suggestions
|
| 75 |
+
st.markdown("<h2 class='sub-header'>π‘ Smart AI Suggestions:</h2>", unsafe_allow_html=True)
|
| 76 |
st.write(suggestions)
|