I have this code: import streamlit as st from src.utils.db import DataBaseManager import…
Private research annotation
Sign in to add a private research label or note.
- User
I have this code:
import streamlit as st from src.utils.db import DataBaseManager import base64 import random import string
def main(): st.title("Email Templates 📝") st.write("Create and manage your email templates.")
codedb_manager = DataBaseManager() # Form to add a new template st.subheader("Add a New Template") with st.form("template_form", clear_on_submit=True): title = st.text_input("Template Title") subject = st.text_input("Subject") body = st.text_area("Body") submitted = st.form_submit_button("Add Template") if submitted: if not title or not subject or not body: st.warning("Please fill in all fields.") else: template_data = { 'title': title, 'subject': subject, 'body': body } db_manager.add_template(template_data) st.success(f"Template '{title}' added successfully!") # st.rerun() # Rerun to update the list after addition # Display existing templates st.subheader("Existing Templates") templates = db_manager.list_templates() if templates: # Search Functionality search_query = st.text_input("Search Templates") if search_query: templates = [t for t in templates if search_query.lower() in t['title'].lower() or search_query.lower() in t['subject'].lower()] if not templates: st.info("No templates match your search.") return # Organize templates in columns cols = st.columns(2) # Adjust the number of columns as needed for idx, template in enumerate(templates): col = cols[idx % 2] with col: display_template(db_manager, template) else: st.info("No templates have been added.") - Assistant