Milind Kamat commited on
Commit
2b772c8
·
1 Parent(s): 95cb33c

2024 Dec 30 :Initial commit

Browse files

Signed-off-by: Milind Kamat <36366961+milindkamat0507@users.noreply.github.com>

Files changed (2) hide show
  1. app.py +144 -0
  2. requirements.txt +10 -0
app.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ from datetime import datetime
5
+
6
+ # Page Configuration
7
+ st.set_page_config(
8
+ page_title="MBA Streamlit Tutorial",
9
+ page_icon="🎓",
10
+ layout="wide"
11
+ )
12
+
13
+ # Main Title
14
+ st.title("Welcome to Streamlit Development Journey 🚀")
15
+ st.markdown("*An interactive guide for MBA students*")
16
+
17
+ # Sidebar
18
+ with st.sidebar:
19
+ st.header("Navigation Panel")
20
+ page = st.radio(
21
+ "Choose your learning path:",
22
+ ["Basic Elements", "Data Display", "Interactive Widgets", "Charts", "Chat Interface"]
23
+ )
24
+
25
+ # User Info Collection
26
+ st.sidebar.markdown("---")
27
+ student_name = st.text_input("Enter your name:")
28
+ experience = st.select_slider(
29
+ "Your coding experience:",
30
+ options=["Beginner", "Intermediate", "Advanced"]
31
+ )
32
+
33
+ # Main Content Based on Selection
34
+ if page == "Basic Elements":
35
+ st.header("Basic Streamlit Elements")
36
+
37
+ tab1, tab2, tab3 = st.tabs(["Text Elements", "Input Elements", "Layout Elements"])
38
+
39
+ with tab1:
40
+ st.subheader("Text Display Options")
41
+ st.write("Regular text using st.write()")
42
+ st.markdown("**Bold text** and *italic text* using markdown")
43
+ st.code("""
44
+ st.write("Regular text")
45
+ st.markdown("**Bold text**")
46
+ """)
47
+
48
+ with tab2:
49
+ st.subheader("Input Elements Demo")
50
+ user_input = st.text_input("Try typing something:")
51
+ st.write("You typed:", user_input)
52
+
53
+ number = st.number_input("Enter a number:", min_value=0, max_value=100)
54
+ st.write("Selected number:", number)
55
+
56
+ with tab3:
57
+ st.subheader("Layout Elements")
58
+ col1, col2 = st.columns(2)
59
+ with col1:
60
+ st.write("This is column 1")
61
+ with col2:
62
+ st.write("This is column 2")
63
+
64
+ elif page == "Data Display":
65
+ st.header("Working with Data")
66
+
67
+ # Sample DataFrame
68
+ df = pd.DataFrame({
69
+ 'Date': pd.date_range('2024-01-01', periods=5),
70
+ 'Sales': np.random.randn(5) * 100 + 500,
71
+ 'Customers': np.random.randint(50, 100, 5)
72
+ })
73
+
74
+ st.dataframe(df)
75
+ st.code("""
76
+ # Create and display a DataFrame
77
+ df = pd.DataFrame({
78
+ 'Date': pd.date_range('2024-01-01', periods=5),
79
+ 'Sales': np.random.randn(5) * 100 + 500,
80
+ 'Customers': np.random.randint(50, 100, 5)
81
+ })
82
+ st.dataframe(df)
83
+ """)
84
+
85
+ elif page == "Interactive Widgets":
86
+ st.header("Interactive Elements")
87
+
88
+ option = st.selectbox(
89
+ 'Select your favorite color',
90
+ ['Red', 'Blue', 'Green', 'Yellow']
91
+ )
92
+
93
+ if st.button('Show Selected Color'):
94
+ st.write(f'Your selected color is {option}')
95
+
96
+ st.slider('Select a range', 0, 100, (25, 75))
97
+
98
+ elif page == "Charts":
99
+ st.header("Data Visualization")
100
+
101
+ # Generate sample data
102
+ chart_data = pd.DataFrame(
103
+ np.random.randn(20, 3),
104
+ columns=['Line A', 'Line B', 'Line C']
105
+ )
106
+
107
+ st.line_chart(chart_data)
108
+ st.code("""
109
+ # Create a line chart
110
+ chart_data = pd.DataFrame(
111
+ np.random.randn(20, 3),
112
+ columns=['Line A', 'Line B', 'Line C']
113
+ )
114
+ st.line_chart(chart_data)
115
+ """)
116
+
117
+ elif page == "Chat Interface":
118
+ st.header("Simple Chatbot Interface")
119
+
120
+ if 'messages' not in st.session_state:
121
+ st.session_state.messages = []
122
+
123
+ # Display chat messages
124
+ for message in st.session_state.messages:
125
+ with st.chat_message(message["role"]):
126
+ st.markdown(message["content"])
127
+
128
+ # Chat input
129
+ if prompt := st.chat_input("What would you like to know about Streamlit?"):
130
+ # Add user message to chat history
131
+ st.session_state.messages.append({"role": "user", "content": prompt})
132
+
133
+ # Simple response logic
134
+ response = f"Thank you for your question about '{prompt}'. This is a demo chatbot interface in Streamlit!"
135
+
136
+ # Add assistant response to chat history
137
+ st.session_state.messages.append({"role": "assistant", "content": response})
138
+
139
+ # Rerun to display new messages
140
+ st.rerun()
141
+
142
+ # Footer
143
+ st.markdown("---")
144
+ st.markdown("Created for MBA Students - Learning Streamlit Development")
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # requirements.txt
2
+
3
+ streamlit>=1.31.0
4
+ pandas>=2.1.0
5
+ numpy>=1.24.0
6
+ plotly>=5.18.0
7
+ datetime
8
+ pillow>=10.0.0
9
+ matplotlib>=3.7.0
10
+ scikit-learn>=1.3.0