tiahchia commited on
Commit
9f7aa41
·
verified ·
1 Parent(s): 48ac605

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -54
app.py CHANGED
@@ -1,63 +1,41 @@
1
  import gradio as gr
2
  from utils import generate_lesson, generate_image
3
 
 
 
 
 
 
 
 
 
 
4
 
5
  def generate(topic):
6
  file_path, _ = generate_lesson(topic)
7
  image_url = generate_image(topic)
8
  return image_url, file_path
9
 
10
- with gr.Blocks(css="""
11
- body {
12
- background-color: #0a0a0a;
13
- color: #ffffff;
14
- font-family: 'JetBrains Mono', monospace;
15
- }
16
- .gradio-container {
17
- background-color: transparent !important;
18
- }
19
- .terminal-box {
20
- background-color: #1e1e1e;
21
- border-radius: 10px;
22
- padding: 20px;
23
- box-shadow: 0 0 20px rgba(250, 41, 188, 0.3);
24
- margin-bottom: 20px;
25
- }
26
- .download-link a {
27
- background-color: #fa29bc;
28
- color: #fff;
29
- padding: 10px 20px;
30
- border-radius: 6px;
31
- text-decoration: none;
32
- font-weight: bold;
33
- transition: all 0.3s ease;
34
- }
35
- .download-link a:hover {
36
- background-color: #ff4dd2;
37
- }
38
- """) as demo:
39
-
40
- gr.Markdown("## 💫 Code Lesson Generator")
41
-
42
- topic_dropdown = gr.Dropdown(
43
- ["Python Basics", "HTML Structure", "CSS Styling", "JavaScript Functions"],
44
- label="Choose a Lesson Topic",
45
- interactive=True
46
- )
47
-
48
- generate_btn = gr.Button("✨ Generate Lesson")
49
-
50
- with gr.Row():
51
- with gr.Column(scale=2):
52
- terminal_preview = gr.Image(label="Lesson Preview", elem_classes="terminal-box")
53
- with gr.Column(scale=1):
54
- lesson_file = gr.File(label="Download Lesson", elem_classes="download-link")
55
-
56
- generate_btn.click(
57
- fn=generate,
58
- inputs=topic_dropdown,
59
- outputs=[terminal_preview, lesson_file],
60
- show_progress="full"
61
- )
62
-
63
- demo.launch()
 
1
  import gradio as gr
2
  from utils import generate_lesson, generate_image
3
 
4
+ TOPICS = [
5
+ "Python Basics",
6
+ "HTML & CSS Fundamentals",
7
+ "JavaScript Loops",
8
+ "React Components",
9
+ "Python OOP",
10
+ "APIs and JSON",
11
+ "Git and Version Control"
12
+ ]
13
 
14
  def generate(topic):
15
  file_path, _ = generate_lesson(topic)
16
  image_url = generate_image(topic)
17
  return image_url, file_path
18
 
19
+
20
+ custom_css = """
21
+ body { background-color: #0d0d0d; color: #00ffcc; font-family: 'Consolas', monospace; }
22
+ footer { display: none !important; }
23
+ #app-title { font-size: 2.2em; font-weight: bold; color: #00ffcc; text-align: center; margin-top: 15px; }
24
+ button { background-color: #00ffcc !important; color: #0d0d0d !important; font-weight: bold; border-radius: 8px; border: none; padding: 10px 16px; }
25
+ button:hover { background-color: #00e6b8 !important; }
26
+ #favicon { display:none; }
27
+ """
28
+
29
+ with gr.Blocks(css=custom_css, title="CodeMode", analytics_enabled=False) as demo:
30
+ gr.HTML("<div id='app-title'>CodeMode — AI Coding Lessons</div>")
31
+
32
+ with gr.Column():
33
+ topic_dropdown = gr.Dropdown(choices=TOPICS, label="Select Lesson Topic", value=TOPICS[0])
34
+ generate_btn = gr.Button("Generate Lesson", variant="primary")
35
+ code_image = gr.Image(label="Lesson Preview", show_download_button=False)
36
+ download_file = gr.File(label="Download Lesson File")
37
+
38
+ generate_btn.click(fn=generate, inputs=topic_dropdown, outputs=[code_image, download_file])
39
+
40
+ if __name__ == "__main__":
41
+ demo.launch()