Spaces:
Running
Running
File size: 1,665 Bytes
c922d24 1445f55 abc0d56 a17207c 65c622b 9f7aa41 1445f55 9f7aa41 48ac605 9a06786 7f0d419 9a06786 7f0d419 65c622b 9a06786 65c622b 9a06786 bf9e5c5 7f0d419 8718061 7f0d419 9f7aa41 bf9e5c5 7f0d419 7a576c1 7f0d419 65c622b 7f0d419 9f7aa41 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import gradio as gr
from utils import generate_lesson
import html
# Beginner coding topics
TOPICS = [
"Introduction to HTML", "CSS Basics", "JavaScript Fundamentals",
"Python Variables", "Python Loops", "Python Functions",
"Classes and Objects in Python", "Dictionaries and Lists",
"SQL Databases", "Parsing Data in Python", "Using Libraries in Python",
"Building a Button in HTML/CSS", "Making a Webpage Layout",
]
css_styles = """
body {
background: #111;
color: #fa29bc;
font-family: monospace;
padding: 20px;
}
footer { display:none; }
button {
background:#fa29bc;
color:white;
border:none;
padding:10px 16px;
border-radius:8px;
cursor:pointer;
}
"""
with gr.Blocks(title="Beginner Coding Lessons", css=css_styles) as demo:
with gr.Column():
topic_dropdown = gr.Dropdown(choices=TOPICS, label="Choose Topic", value=TOPICS[0])
generate_btn = gr.Button("Generate Lesson")
# Standard Markdown output for lessons
lesson_output = gr.Markdown()
# Status message for "please wait"
status_label = gr.Label(value="")
def generate(topic):
# Show "please wait" message
status_label.value = "✨ Your lesson is being generated... please wait!"
# Generate the lesson
file_path, lesson_text = generate_lesson(topic)
# Clear the status message
status_label.value = ""
return lesson_text, status_label.value
generate_btn.click(fn=generate, inputs=topic_dropdown, outputs=[lesson_output, status_label])
if __name__ == "__main__":
demo.launch()
|