ElmiraManavi commited on
Commit
75280e5
·
1 Parent(s): 0b2c8df

initial commit

Browse files
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ /.idea/
2
+ /.venv/
3
+ /.env
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
src/pages/Eventfinder.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from streamlit import streamlit as st
4
+ from streamlit.components.v1 import html
5
+
6
+ from dotenv import load_dotenv
7
+ from pymongo import MongoClient
8
+
9
+
10
+ @st.cache_resource
11
+ def init_connection():
12
+ load_dotenv()
13
+ uri = f"mongodb+srv://{os.getenv('MONGO_USERNAME')}:{os.getenv('MONGO_PASSWORD')}@{os.getenv('MONGO_HOST')}/?retryWrites=true&w=majority&appName=Cluster0"
14
+ client = MongoClient(uri)
15
+ return client.event_data
16
+
17
+
18
+ def display_event(event_data):
19
+ title = event_data.get("title")
20
+ st.write(f"**{title or '-'}**")
21
+
22
+ schedule = event_data.get("schedule", [])
23
+ if schedule:
24
+ for schedule_entry in schedule:
25
+ start_date = schedule_entry.get("startdate")
26
+ if start_date:
27
+ start_date = start_date.strftime("%d.%m.%Y")
28
+ end_date = schedule_entry.get("enddate")
29
+ if end_date:
30
+ end_date = end_date.strftime("%d.%m.%Y")
31
+ start_time = schedule_entry.get("starttime")
32
+ if start_time:
33
+ start_time = start_time.strftime("%H:%M")
34
+ end_time = schedule_entry.get("endtime")
35
+ if end_time:
36
+ end_time = end_time.strftime("%H:%M")
37
+
38
+ st.write(
39
+ f"🗓️ Start: {(start_date or '')} {start_time or ''} | "
40
+ f"Ende: {end_date or ''} {end_time or ''}"
41
+ )
42
+ else:
43
+ st.write(f"🗓️ - ")
44
+
45
+ locations = event_data.get("locations", [])
46
+
47
+ for location in locations:
48
+ st.write(f" 📍 {location.get('geolocation', {}).get('formatted')}")
49
+ if location.get("additional_directions"):
50
+ st.write(f" 💡 {location.get('additional_directions')}")
51
+
52
+ url = event_data.get("url")
53
+ st.link_button("Mehr Infos", url=url)
54
+
55
+
56
+ db = init_connection()
57
+
58
+ count = db.events.count_documents({})
59
+ events = db.events.find({})
60
+
61
+ st.write(f"{count} events found")
62
+
63
+ with st.container(height=600):
64
+ for event in events:
65
+ print(event)
66
+
67
+ with st.container(border=True):
68
+ display_event(event)
src/streamlit_app.py CHANGED
@@ -1,40 +1 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
5
-
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
1
  import streamlit as st