design web app for list of students enroll to a tuition class. student can enroll or unregister from front ui. students needs to get syllabus and registration fees ,duration information after registration
To upload files, please first save the app
import streamlit as st
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import declarative_base, Session
Base = declarative_base()
class Student(Base):
__tablename__ = 'students'
id = Column(Integer, primary_key=True)
name = Column(String)
enrolled = Column(Integer, default=0) # 0 for unregistered, 1 for enrolled
engine = create_engine('sqlite:///tuition_classes.db')
Base.metadata.create_all(bind=engine)
st.title('Tuition Class Enrollment')
# UI to enroll/unregister students
name = st.text_input('Enter Student Name')
with Session(engine) as session:
if st.button('Enroll'):
if name:
student = Student(name=name, enrolled=1)
session.add(student)
session.commit()
st.success(f'{name} enrolled successfully!')
if st.button('Unregister'):
if name:
student = session.query(Student).filter(Student.name == name).first()
if student:
student.enrolled = 0
session.commit()
st.success(f'{name} unregistered successfully!')
else:
st.error('Student not found!')
# Display enrolled students
st.markdown('### Enrolled Students:')
students = session.query(Student).filter(Student.enrolled == 1).all()
if students:
st.write([student.name for student in students])
else:
st.write('No students are currently enrolled.')
# Syllabus and fee information
st.markdown('### Course Information')
st.write('* Syllabus: [Insert Syllabus Here]*')
st.write('* Registration Fees: $100')
st.write('* Duration: 3 months')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?