yunuseduran commited on
Commit
a9f4515
·
verified ·
1 Parent(s): d9b5d65

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -0
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+
4
+ # Uygulama başlığı ve stil ayarları
5
+ st.set_page_config(page_title="Etsy Profit Margin Calculator", layout="wide")
6
+
7
+ # CSS for custom styling
8
+ st.markdown("""
9
+ <style>
10
+ .card {
11
+ background-color: #f8f9fa;
12
+ border-radius: 10px;
13
+ padding: 20px;
14
+ margin: 10px 0;
15
+ box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
16
+ }
17
+ .icon {
18
+ font-size: 30px;
19
+ margin-right: 10px;
20
+ }
21
+ .calculate-button {
22
+ background-color: #007bff;
23
+ color: white;
24
+ border: none;
25
+ padding: 10px 20px;
26
+ border-radius: 5px;
27
+ font-size: 18px;
28
+ cursor: pointer;
29
+ }
30
+ .header {
31
+ font-size: 24px;
32
+ font-weight: bold;
33
+ }
34
+ </style>
35
+ """, unsafe_allow_html=True)
36
+
37
+ # Üst başlık ve açıklama
38
+ st.markdown("<h2 style='text-align: center;'>Calculate Your Profit Margin on Etsy, Don’t Make A LOSS!</h2>", unsafe_allow_html=True)
39
+
40
+ # Kullanıcı girdi alanları
41
+ col1, col2, col3 = st.columns(3)
42
+
43
+ with col1:
44
+ st.markdown("<div class='card'><span class='icon'>💰</span> <span class='header'>Store Currency</span>", unsafe_allow_html=True)
45
+ currency = st.selectbox("Currency", ["USD", "EUR"])
46
+
47
+ st.markdown("<div class='card'><span class='icon'>🌍</span> <span class='header'>Store Location</span>", unsafe_allow_html=True)
48
+ location = st.selectbox("Location", ["US", "EU", "Other"])
49
+
50
+ with col2:
51
+ st.markdown("<div class='card'><span class='icon'>💲</span> <span class='header'>Revenue</span>", unsafe_allow_html=True)
52
+ sale_price = st.number_input("Sale Price ($)", min_value=0.0)
53
+ shipping_price = st.number_input("Shipping Price ($)", min_value=0.0)
54
+ gift_wrap = st.number_input("Gift Wrap Price ($)", min_value=0.0)
55
+
56
+ with col3:
57
+ st.markdown("<div class='card'><span class='icon'>💸</span> <span class='header'>Cost</span>", unsafe_allow_html=True)
58
+ product_cost = st.number_input("Product Cost ($)", min_value=0.0)
59
+ labor_cost = st.number_input("Labor Cost ($)", min_value=0.0)
60
+ packaging_cost = st.number_input("Packaging Cost ($)", min_value=0.0)
61
+
62
+ # Hesaplama
63
+ if st.button("Hesapla", key="calculate"):
64
+ total_revenue = sale_price + shipping_price + gift_wrap
65
+ total_cost = product_cost + labor_cost + packaging_cost
66
+ profit = total_revenue - total_cost
67
+ profit_margin = (profit / total_revenue) * 100 if total_revenue > 0 else 0
68
+
69
+ # Sonuçları göster
70
+ st.markdown("<div class='card'><span class='icon'>📊</span> <span class='header'>Results</span>", unsafe_allow_html=True)
71
+ st.write("Total Revenue: $", total_revenue)
72
+ st.write("Total Cost: $", total_cost)
73
+ st.write("Profit: $", profit)
74
+ st.write("Profit Margin: ", f"{profit_margin:.2f}%")
75
+
76
+ # Pasta grafiği
77
+ labels = ["Cost", "Profit"]
78
+ sizes = [total_cost, profit]
79
+ colors = ["#ff9999", "#66b3ff"]
80
+ fig1, ax1 = plt.subplots()
81
+ ax1.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90)
82
+ ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
83
+
84
+ st.pyplot(fig1)