Spaces:
Runtime error
Runtime error
| from fasthtml.common import * | |
| from monsterui.all import * | |
| subject_topic_options = { | |
| "biology":[ | |
| "Introduction to Biology", | |
| "Cells", | |
| "Classification", | |
| "The Five Kingdoms of Living Organisms", | |
| "Viruses", | |
| "Insects", | |
| "Flowering Plants", | |
| "Physical and Chemical Properties of Soil", | |
| "Soil Erosion and Conservation: Causes, Effects, and Prevention", | |
| "Nutrition Types and Nutrient Compounds", | |
| "Nutrition in Green Plants", | |
| "Nutrition in Mammals" | |
| ], | |
| "chemistry":[ | |
| "Energy changes during chemical reactions", | |
| "Atomic structure and nuclear processes", | |
| "Using materials", | |
| "Carbon in life", | |
| "Temporary and permanent changes to materials", | |
| "Mixtures, elements and compounds", | |
| "Structures and bonds", | |
| "Air", | |
| "Formulae, stoichiometry and mole concept", | |
| "Oxidation and reduction reactions", | |
| "Industrial processes", | |
| "Chemicals for consumers", | |
| "States and changes of states of matter", | |
| "The periodic table", | |
| "Trends in the periodic table"], | |
| "physics":[ | |
| "Reflection of Light by Curved Surfaces", | |
| "The Effects of Forces", | |
| "Nuclear Decay and Radioactivity", | |
| "The Solar System", | |
| "Linear and Non-linear Motion", | |
| "Heat and Temperature", | |
| "Modes of Heat Transfer", | |
| "Refraction of Light", | |
| "Thermal Expansion", | |
| "Light Sources and Reflection", | |
| "Electricity Distribution and Safety", | |
| "Waves and Energy Transmission", | |
| "Work, Energy, and Power", | |
| "Sound Waves", | |
| "Heat Quantities and Vapours", | |
| "Turning Effect of Forces and Stability", | |
| "Stars and Stellar Evolution", | |
| "Pressure in Solids and Fluids", | |
| "Current Electricity", | |
| "Magnetic Materials and Fields", | |
| "Physics and Laboratory Practice", | |
| "Voltage, Resistance, and Ohm’s Law", | |
| "Mechanical Properties of Materials", | |
| "Measurements in Physics", | |
| "Electromagnetic Effects", | |
| "States of Matter", | |
| "Atomic Structure", | |
| "Electrostatics", | |
| "Satellites and Communication", | |
| "Digital Electronics" | |
| ], | |
| "entrepreneurship":[ | |
| "Creating an Entrepreneurial Awareness", | |
| "Introduction to Entrepreneurship Education", | |
| "Scanning the environment", | |
| "Businesses in Uganda", | |
| "Business Ideas and Business Opportunities", | |
| "Business Start-up Process", | |
| "Introduction to Government Revenue", | |
| "Legal Forms of Business Ownership", | |
| "Production in Business", | |
| "Marketing in a Small Business Enterprise", | |
| "Money and Financial Institutions", | |
| "Taxation", | |
| "Business Planning", | |
| "Introduction to Principles of Accounting", | |
| "Tax Administration" | |
| ], | |
| "cre":[ | |
| "Worship", | |
| "Christian Rituals and celebrations", | |
| "Values in Christianity, Islam and African Traditional Religion", | |
| "Respect for human life", | |
| "Marriage", | |
| "Family" | |
| ] | |
| } | |
| def generate_topic_options(selected_subject): | |
| topics = subject_topic_options.get(selected_subject.lower(), []) | |
| return [Option(topic, value=topic) for topic in topics] | |
| def app_content(): | |
| subject_select = LabelSelect( | |
| Option('Biology', value='biology'), | |
| Option('Chemistry',value ='chemistry'), | |
| Option('Physics',value ='physics'), | |
| Option('Entrepreneurship',value ='entrepreneurship'), | |
| Option('CRE',value ='cre'), | |
| label='Subject', | |
| id='subject-select', | |
| name='subject', | |
| hx_post='/get_topics', | |
| hx_trigger='change', | |
| hx_target='#topic-select-container', | |
| hx_swap='innerHTML' | |
| ) | |
| topic_select_container = Div( | |
| LabelSelect( | |
| Option(value="", disabled=True, selected=True)("Select a subject first"), | |
| label="Topic", | |
| name="topic", | |
| id="topic-select", # Changed the ID here | |
| ), | |
| id="topic-select-container", | |
| ) | |
| return Div( | |
| Aside( | |
| H2('Fraims AI'), | |
| Form( | |
| subject_select, | |
| topic_select_container, | |
| Button('Generate'), | |
| hx_post='/generate_aoi', | |
| hx_target ='#results', | |
| hx_swap ='innerHTML' | |
| ), | |
| Div( | |
| Button('🌙', data_uk_toggle="target: #my-modal"), | |
| Modal( | |
| ModalTitle("Simple Test Modal"), | |
| DivCentered(ThemePicker(),), | |
| footer=ModalCloseButton(UkIcon('x', height=15, width=15), cls=ButtonT.primary), | |
| id='my-modal', | |
| body_cls='space-y-4 px-30', | |
| ), | |
| Button('Upgrade', cls='bg-gray-800 text-white px-4 py-2 rounded hover:bg-purple-600'), | |
| cls='flex items-center gap-3' | |
| ), | |
| Div( | |
| P('Fraims is Still in Development', cls='font-semibold mb-1'), | |
| P('This is the Beta Version. A lot of utilities and features are still development and testing', cls='text-sm mb-3'), | |
| A(Button('Tell Us Something', cls='bg-purple-500 text-white w-full py-2 rounded hover:bg-purple-600'),href =f'''mailto:ocholamarkjoshuae@gmail.com'''), | |
| cls='bg-purple-100 text-purple-900 p-4 rounded-lg mt-6' | |
| ), | |
| cls='hidden md:flex w-64 p-6 flex-col justify-between' | |
| ), | |
| Main( | |
| Div( | |
| Div( | |
| H2('Generate AOIs for any subject'), | |
| Div(id ='results',) | |
| ), | |
| cls='hidden md:flex justify-center items-center mb-6' | |
| ), | |
| cls='flex-1 p-6 md:p-10' | |
| ), | |
| cls='flex flex-col md:flex-row min-h-screen' | |
| ) | |