trohith89 commited on
Commit
3cebf92
Β·
verified Β·
1 Parent(s): a7850bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
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: #0E0E0E; color: #FFFFFF;}
14
- .main-title {text-align: center; font-size: 40px; font-weight: bold; color: #FFA500;}
15
- .sub-header {text-align: center; font-size: 25px; font-weight: bold; color: #FFD700;}
16
- .stTextArea textarea {background-color: #222; color: #FFA500; border-radius: 10px;}
17
- .stButton button {background-color: #FF4500; color: white; font-size: 18px; border-radius: 10px;}
18
- .stDownloadButton button {background-color: #32CD32; color: white; font-size: 18px; border-radius: 10px;}
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} πŸš€</h1>', unsafe_allow_html=True)
29
  time.sleep(speed)
30
 
31
  # Animated Welcome Text
32
- animated_text("Welcome to AI Code Debugger & Optimizer!")
33
 
34
  # Streamlit Layout
35
- st.markdown("<h2 class='sub-header'>πŸš€ AI-Powered Code Debugging & Enhancement</h2>", unsafe_allow_html=True)
36
 
37
  # User Input for Buggy Code
38
- buggy_code = st.text_area("🐞 Paste your buggy code below:", height=200)
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("πŸ› οΈ Debugging your code..."):
57
  fixed_code = debug_code_with_gemini(buggy_code)
58
 
59
- with st.spinner("πŸ” Generating optimization suggestions..."):
60
  suggestions = get_suggestions_with_gemini(fixed_code)
61
 
62
  # Display Debugged Code
63
- st.markdown("<h2 class='sub-header'>βœ… Fixed 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 Fixed Code",
69
  data=fixed_code,
70
- file_name="fixed_code.py",
71
  mime="text/plain"
72
  )
73
 
74
  # Display AI Suggestions
75
- st.markdown("<h2 class='sub-header'>πŸ’‘ AI-Generated Suggestions:</h2>", unsafe_allow_html=True)
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)