Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .gitignore +3 -0
- README.md +23 -12
- app.py +105 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__/
|
2 |
+
*.csv
|
3 |
+
*.pyc
|
README.md
CHANGED
@@ -1,12 +1,23 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 📣 PromoPlaner – Marketing Kampagnen Tool
|
2 |
+
|
3 |
+
Ein einfaches Webtool zur Organisation und Visualisierung von Werbeaktionen mit Gradio und Plotly.
|
4 |
+
|
5 |
+
## Funktionen
|
6 |
+
- 🔐 Login-Funktion
|
7 |
+
- 💡 KI-basierte Kampagnenvorschläge
|
8 |
+
- 📅 Planung mit Start- und Enddatum
|
9 |
+
- 📈 Gantt-Visualisierung der Kampagnen
|
10 |
+
- 📤 CSV-Export
|
11 |
+
|
12 |
+
## Nutzung
|
13 |
+
|
14 |
+
```bash
|
15 |
+
pip install -r requirements.txt
|
16 |
+
python app.py
|
17 |
+
```
|
18 |
+
|
19 |
+
## Deployment auf Hugging Face
|
20 |
+
```bash
|
21 |
+
huggingface-cli login
|
22 |
+
gradio deploy
|
23 |
+
```
|
app.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from datetime import datetime
|
3 |
+
import plotly.express as px
|
4 |
+
import plotly.io as pio
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
users = {"PM": "Promo123"}
|
8 |
+
campaigns = []
|
9 |
+
sessions = {}
|
10 |
+
|
11 |
+
def validate_date(date_str):
|
12 |
+
try:
|
13 |
+
datetime.strptime(date_str, "%Y-%m-%d")
|
14 |
+
return True
|
15 |
+
except:
|
16 |
+
return False
|
17 |
+
|
18 |
+
def login(username, password):
|
19 |
+
if users.get(username) == password:
|
20 |
+
sessions["user"] = username
|
21 |
+
return gr.update(visible=True), f"Willkommen {username}"
|
22 |
+
return gr.update(visible=False), "❌ Login fehlgeschlagen"
|
23 |
+
|
24 |
+
def suggest_campaign(product, goal, channel):
|
25 |
+
return f"""💡 Idee:
|
26 |
+
Produkt: {product}
|
27 |
+
Ziel: {goal}
|
28 |
+
Kanal: {channel}
|
29 |
+
|
30 |
+
🚀 Vorschlag:
|
31 |
+
Eine kreative {channel}-Kampagne für {product}, z. B. mit exklusiven Angeboten oder Rabattaktionen.
|
32 |
+
"""
|
33 |
+
|
34 |
+
def add_campaign(name, goal, product, channel, start, end, budget, responsible):
|
35 |
+
if not validate_date(start) or not validate_date(end):
|
36 |
+
return pd.DataFrame(campaigns), "❌ Bitte Datum im Format YYYY-MM-DD eingeben."
|
37 |
+
campaigns.append({
|
38 |
+
"Name": name,
|
39 |
+
"Ziel": goal,
|
40 |
+
"Produkt": product,
|
41 |
+
"Kanal": channel,
|
42 |
+
"Start": start,
|
43 |
+
"Ende": end,
|
44 |
+
"Budget (CHF)": budget,
|
45 |
+
"Verantwortlich": responsible
|
46 |
+
})
|
47 |
+
df = pd.DataFrame(campaigns)
|
48 |
+
total = df["Budget (CHF)"].sum()
|
49 |
+
return df, f"💰 Gesamtbudget: CHF {total:.2f}"
|
50 |
+
|
51 |
+
def export_csv():
|
52 |
+
path = "kampagnen.csv"
|
53 |
+
pd.DataFrame(campaigns).to_csv(path, index=False)
|
54 |
+
return path
|
55 |
+
|
56 |
+
def generate_gantt():
|
57 |
+
if not campaigns:
|
58 |
+
return "<i>Keine Kampagnen zum Anzeigen</i>"
|
59 |
+
df = pd.DataFrame(campaigns)
|
60 |
+
df["Start"] = pd.to_datetime(df["Start"])
|
61 |
+
df["Ende"] = pd.to_datetime(df["Ende"])
|
62 |
+
try:
|
63 |
+
fig = px.timeline(df, x_start="Start", x_end="Ende", y="Name", color="Verantwortlich", title="📊 Kampagnenübersicht")
|
64 |
+
fig.update_yaxes(autorange="reversed")
|
65 |
+
fig.update_layout(height=400, margin=dict(l=20, r=20, t=30, b=20))
|
66 |
+
html = pio.to_html(fig, full_html=False, include_plotlyjs='cdn')
|
67 |
+
return html
|
68 |
+
except Exception as e:
|
69 |
+
return f"<b>Fehler:</b> {e}"
|
70 |
+
|
71 |
+
with gr.Blocks() as app:
|
72 |
+
gr.Markdown("## 📣 Promo-Planer mit Visualisierung")
|
73 |
+
with gr.Row():
|
74 |
+
user = gr.Textbox(label="Benutzer")
|
75 |
+
pw = gr.Textbox(label="Passwort", type="password")
|
76 |
+
login_btn = gr.Button("🔓 Login")
|
77 |
+
login_status = gr.Textbox(interactive=False)
|
78 |
+
with gr.Column(visible=False) as planner:
|
79 |
+
with gr.Row():
|
80 |
+
name = gr.Textbox(label="Kampagnenname")
|
81 |
+
goal = gr.Dropdown(["Verkaufsförderung","Werbung", "Event"], label="Ziel")
|
82 |
+
product = gr.Textbox(label="Produkt")
|
83 |
+
with gr.Row():
|
84 |
+
channel = gr.Dropdown(["Tisch","Instagram", "E-Mail", "Plakat"], label="Kanal")
|
85 |
+
start = gr.Textbox(label="Startdatum (YYYY-MM-DD)")
|
86 |
+
end = gr.Textbox(label="Enddatum (YYYY-MM-DD)")
|
87 |
+
with gr.Row():
|
88 |
+
budget = gr.Number(label="Budget (CHF)")
|
89 |
+
responsible = gr.Dropdown(["Markthalle","Marketing", "PM", "PED"], label="Verantwortlich")
|
90 |
+
suggest_btn = gr.Button("💡 KI-Vorschlag")
|
91 |
+
idea = gr.Textbox(label="Kampagnenidee")
|
92 |
+
submit_btn = gr.Button("✅ Speichern")
|
93 |
+
output_table = gr.Dataframe()
|
94 |
+
budget_total = gr.Textbox(label="Budget Gesamt", interactive=False)
|
95 |
+
export_btn = gr.Button("📤 Export CSV")
|
96 |
+
gr.Markdown("### 📈 Gantt-Visualisierung")
|
97 |
+
gantt_html = gr.HTML()
|
98 |
+
update_chart = gr.Button("🔄 Visualisierung aktualisieren")
|
99 |
+
gr.Markdown("🚀 **Deployment-Tipp**: Führe `gradio deploy` im Terminal aus, um diese App auf [Hugging Face Spaces](https://huggingface.co/spaces) zu veröffentlichen.")
|
100 |
+
login_btn.click(login, [user, pw], [planner, login_status])
|
101 |
+
suggest_btn.click(suggest_campaign, [product, goal, channel], idea)
|
102 |
+
submit_btn.click(add_campaign, [name, goal, product, channel, start, end, budget, responsible], [output_table, budget_total])
|
103 |
+
export_btn.click(export_csv, outputs=None)
|
104 |
+
update_chart.click(generate_gantt, outputs=gantt_html)
|
105 |
+
app.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio>=4.18
|
2 |
+
pandas
|
3 |
+
plotly
|