Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import random
|
4 |
+
from datetime import datetime
|
5 |
+
|
6 |
+
# Helper function to generate a random date within the last year
|
7 |
+
def random_date():
|
8 |
+
start_date = datetime.now() - timedelta(days=365)
|
9 |
+
random_days = random.randint(0, 365)
|
10 |
+
return (start_date + timedelta(days=random_days)).strftime("%Y-%m-%d")
|
11 |
+
|
12 |
+
# Cache the function that loads the product catalog
|
13 |
+
@st.cache
|
14 |
+
|
15 |
+
# Define the products and their categories
|
16 |
+
products = {
|
17 |
+
"Product Name": [
|
18 |
+
"Notepad++", "WinRAR", "7-Zip", "CCleaner", "TeamViewer",
|
19 |
+
"FileZilla", "PuTTY", "WinSCP", "Everything", "Greenshot",
|
20 |
+
"Visual Studio Code", "JetBrains IntelliJ IDEA", "Sublime Text", "Atom", "Eclipse",
|
21 |
+
"PyCharm", "NetBeans", "Xcode", "Android Studio", "GitLab",
|
22 |
+
"Norton Antivirus", "McAfee Total Protection", "Kaspersky Internet Security", "Bitdefender Antivirus Plus", "Avast Free Antivirus",
|
23 |
+
"Sophos Home", "Trend Micro Antivirus+", "ESET NOD32 Antivirus", "F-Secure SAFE", "Malwarebytes",
|
24 |
+
"Microsoft Office 365", "Google Workspace", "Slack", "Trello", "Asana",
|
25 |
+
"Zoom", "Evernote", "Notion", "Dropbox", "Adobe Acrobat Reader",
|
26 |
+
"Adobe Photoshop", "Adobe Illustrator", "Adobe Premiere Pro", "Final Cut Pro", "Sketch",
|
27 |
+
"Blender", "Autodesk Maya", "CorelDRAW", "GIMP", "Inkscape"
|
28 |
+
],
|
29 |
+
"Category": [
|
30 |
+
"Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools",
|
31 |
+
"Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools",
|
32 |
+
"Development Tools", "Development Tools", "Development Tools", "Development Tools", "Development Tools",
|
33 |
+
"Development Tools", "Development Tools", "Development Tools", "Development Tools", "Development Tools",
|
34 |
+
"Security Software", "Security Software", "Security Software", "Security Software", "Security Software",
|
35 |
+
"Security Software", "Security Software", "Security Software", "Security Software", "Security Software",
|
36 |
+
"Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software",
|
37 |
+
"Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software",
|
38 |
+
"Creative Software", "Creative Software", "Creative Software", "Creative Software", "Creative Software",
|
39 |
+
"Creative Software", "Creative Software", "Creative Software", "Creative Software", "Creative Software"
|
40 |
+
],
|
41 |
+
"Cyber Approved": [random.choice([True, False]) for _ in range(50)],
|
42 |
+
"Accessibility Approved": [random.choice([True, False]) for _ in range(50)],
|
43 |
+
"Privacy Approved": [random.choice([True, False]) for _ in range(50)],
|
44 |
+
"Review Date": [random_date() for _ in range(50)]
|
45 |
+
}
|
46 |
+
|
47 |
+
# Example of caching a complex filtering operation
|
48 |
+
@st.cache
|
49 |
+
def filter_catalog(catalog, category=None, search_query=None):
|
50 |
+
filtered = catalog
|
51 |
+
if category:
|
52 |
+
filtered = filtered[filtered["Category"].isin(category)]
|
53 |
+
if search_query:
|
54 |
+
filtered = filtered[filtered["Product Name"].str.contains(search_query, case=False)]
|
55 |
+
return filtered
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
# Create the DataFrame
|
60 |
+
catalog = pd.DataFrame(products)
|
61 |
+
|
62 |
+
# Apply filters based on user input
|
63 |
+
category = st.sidebar.multiselect("Filter by Category", options=catalog["Category"].unique())
|
64 |
+
search_query = st.sidebar.text_input("Search Products")
|
65 |
+
|
66 |
+
filtered_catalog = filter_catalog(catalog, category, search_query)
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
# Display the DataFrame for verification
|
71 |
+
print(catalog)
|
72 |
+
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
# Streamlit app layout
|
77 |
+
st.title("Enterprise Software Product Catalog")
|
78 |
+
st.write("This is the source of truth for app approval statuses within the enterprise.")
|
79 |
+
|
80 |
+
# Sidebar for filters
|
81 |
+
category = st.sidebar.multiselect("Filter by Category", options=catalog["Category"].unique())
|
82 |
+
cyber_approved = st.sidebar.checkbox("Cyber Approved")
|
83 |
+
accessibility_approved = st.sidebar.checkbox("Accessibility Approved")
|
84 |
+
privacy_approved = st.sidebar.checkbox("Privacy Approved")
|
85 |
+
|
86 |
+
|
87 |
+
# Filtering logic
|
88 |
+
filtered_catalog = catalog
|
89 |
+
if category:
|
90 |
+
filtered_catalog = filtered_catalog[filtered_catalog["Category"].isin(category)]
|
91 |
+
if cyber_approved:
|
92 |
+
filtered_catalog = filtered_catalog[filtered_catalog["Cyber Approved"] == True]
|
93 |
+
if accessibility_approved:
|
94 |
+
filtered_catalog = filtered_catalog[filtered_catalog["Accessibility Approved"] == True]
|
95 |
+
if privacy_approved:
|
96 |
+
filtered_catalog = filtered_catalog[filtered_catalog["Privacy Approved"] == True]
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
# Display the filtered product catalog
|
101 |
+
st.dataframe(filtered_catalog)
|
102 |
+
|
103 |
+
|