diff --git a/files/visitor_locations.db b/files/visitor_locations.db new file mode 100644 index 000000000..61cbf36e6 Binary files /dev/null and b/files/visitor_locations.db differ diff --git a/images/BuffaloMarker.png b/images/BuffaloMarker.png new file mode 100644 index 000000000..66dd519ba Binary files /dev/null and b/images/BuffaloMarker.png differ diff --git a/webpages/__pycache__/__init__.cpython-312.pyc b/webpages/__pycache__/__init__.cpython-312.pyc index 7196b9be6..e133c0396 100644 Binary files a/webpages/__pycache__/__init__.cpython-312.pyc and b/webpages/__pycache__/__init__.cpython-312.pyc differ diff --git a/webpages/__pycache__/classroom.cpython-312.pyc b/webpages/__pycache__/classroom.cpython-312.pyc index 431ec9a64..04efaeff0 100644 Binary files a/webpages/__pycache__/classroom.cpython-312.pyc and b/webpages/__pycache__/classroom.cpython-312.pyc differ diff --git a/webpages/__pycache__/code_editor.cpython-312.pyc b/webpages/__pycache__/code_editor.cpython-312.pyc index 23df01739..06aa7b6b3 100644 Binary files a/webpages/__pycache__/code_editor.cpython-312.pyc and b/webpages/__pycache__/code_editor.cpython-312.pyc differ diff --git a/webpages/__pycache__/event.cpython-312.pyc b/webpages/__pycache__/event.cpython-312.pyc index 3139fe1d4..282285ec5 100644 Binary files a/webpages/__pycache__/event.cpython-312.pyc and b/webpages/__pycache__/event.cpython-312.pyc differ diff --git a/webpages/__pycache__/home.cpython-312.pyc b/webpages/__pycache__/home.cpython-312.pyc index d1210eb5d..8d6260f53 100644 Binary files a/webpages/__pycache__/home.cpython-312.pyc and b/webpages/__pycache__/home.cpython-312.pyc differ diff --git a/webpages/__pycache__/join_us.cpython-312.pyc b/webpages/__pycache__/join_us.cpython-312.pyc index bf2b0b6c6..ae8386af4 100644 Binary files a/webpages/__pycache__/join_us.cpython-312.pyc and b/webpages/__pycache__/join_us.cpython-312.pyc differ diff --git a/webpages/__pycache__/navigation.cpython-312.pyc b/webpages/__pycache__/navigation.cpython-312.pyc index fb04ca9ab..bb62e99f9 100644 Binary files a/webpages/__pycache__/navigation.cpython-312.pyc and b/webpages/__pycache__/navigation.cpython-312.pyc differ diff --git a/webpages/__pycache__/outstanding_members.cpython-312.pyc b/webpages/__pycache__/outstanding_members.cpython-312.pyc index 26039df77..fcfaaee2a 100644 Binary files a/webpages/__pycache__/outstanding_members.cpython-312.pyc and b/webpages/__pycache__/outstanding_members.cpython-312.pyc differ diff --git a/webpages/__pycache__/project.cpython-312.pyc b/webpages/__pycache__/project.cpython-312.pyc index 765f42e0e..176d3b754 100644 Binary files a/webpages/__pycache__/project.cpython-312.pyc and b/webpages/__pycache__/project.cpython-312.pyc differ diff --git a/webpages/__pycache__/reference.cpython-312.pyc b/webpages/__pycache__/reference.cpython-312.pyc index cfdc6faed..9d7b7d78b 100644 Binary files a/webpages/__pycache__/reference.cpython-312.pyc and b/webpages/__pycache__/reference.cpython-312.pyc differ diff --git a/webpages/__pycache__/testing.cpython-312.pyc b/webpages/__pycache__/testing.cpython-312.pyc index 551eeaa2c..32af22229 100644 Binary files a/webpages/__pycache__/testing.cpython-312.pyc and b/webpages/__pycache__/testing.cpython-312.pyc differ diff --git a/webpages/cis_tech_challenge_pages/__pycache__/cis_tech_challenge_homepage.cpython-312.pyc b/webpages/cis_tech_challenge_pages/__pycache__/cis_tech_challenge_homepage.cpython-312.pyc index 46128db09..0c718a264 100644 Binary files a/webpages/cis_tech_challenge_pages/__pycache__/cis_tech_challenge_homepage.cpython-312.pyc and b/webpages/cis_tech_challenge_pages/__pycache__/cis_tech_challenge_homepage.cpython-312.pyc differ diff --git a/webpages/input_code.py b/webpages/input_code.py index 5328929cc..d522c5bf8 100644 --- a/webpages/input_code.py +++ b/webpages/input_code.py @@ -1,10 +1,2 @@ -# Example 1 -Age = 24; -if Age >=18: - print('You are an adult') - -# Example 2 -has_license = False -if has_license == True: # False == True-> Flase - print('You can drive') -print('False condition, skip the if statement') \ No newline at end of file +# Example 1: put following code in the editor and click APPLY to run +print("Hello PythonX") \ No newline at end of file diff --git a/webpages/navigation.py b/webpages/navigation.py index f228b45c0..6db03b6bd 100644 --- a/webpages/navigation.py +++ b/webpages/navigation.py @@ -10,7 +10,7 @@ def navigation_bar(): with st.sidebar: st.image("./images/BuffTeksLogo.png", caption="Building Skills, Crafting Code, Bridging Communities") - + page_label = sac.menu([ sac.MenuItem('Homepage', icon='house'), sac.MenuItem('Outstanding Members', icon='award'), @@ -27,7 +27,7 @@ def navigation_bar(): sac.MenuItem('Lesson3', icon='3-square'), ]), ]), - # sac.MenuItem("Testing", icon='fingerprint'), + sac.MenuItem("Testing", icon='fingerprint'), sac.MenuItem(type='divider'), sac.MenuItem('Link', type='group', children=[ sac.MenuItem('Join Us', icon='person-plus', href='https://wtamuuw.az1.qualtrics.com/jfe/form/SV_2boQtKLCptO33HE'), diff --git a/webpages/project.py b/webpages/project.py index b64110f4a..65018927f 100644 --- a/webpages/project.py +++ b/webpages/project.py @@ -1,4 +1,5 @@ import streamlit as st +import streamlit_antd_components as sac import time def project(): @@ -13,12 +14,22 @@ def project(): # Project Gallery st.header("Project Gallery") st.divider() - st.image("./images/CommunityLinkLogo.svg") - st.markdown(""" - ### Main Contributors: - - Darrian Lambert, Kim Sundblom, and Jessica Zoll + col_logo, clo_contributors = st.columns(2) + with col_logo: + st.image("./images/CommunityLinkLogo.svg") + with clo_contributors: + st.markdown(""" + #### Main Contributors: + - Darrian Lambert + - Kim Sundblom + - Jessica Zoll + """) + sac.buttons([ + sac.ButtonsItem(label='View Source Code', icon='github',color='#000000', href='https://github.com/wtamu-buffteks/CommunityLink'), + ], label='', align='left') + st.markdown(""" ### Introduction: - The Community Link project is dedicated to efficiently organizing, tracking, and distributing hard goods and monetary contributions in support of non-profit organizations. diff --git a/webpages/pythonx_lessons_pages/__pycache__/pythonx_homepage.cpython-312.pyc b/webpages/pythonx_lessons_pages/__pycache__/pythonx_homepage.cpython-312.pyc index fbd00bd91..0f57484a2 100644 Binary files a/webpages/pythonx_lessons_pages/__pycache__/pythonx_homepage.cpython-312.pyc and b/webpages/pythonx_lessons_pages/__pycache__/pythonx_homepage.cpython-312.pyc differ diff --git a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson1.cpython-312.pyc b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson1.cpython-312.pyc index da262f1cb..e92d76624 100644 Binary files a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson1.cpython-312.pyc and b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson1.cpython-312.pyc differ diff --git a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson2.cpython-312.pyc b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson2.cpython-312.pyc index 26a7ead98..02ddb0f7d 100644 Binary files a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson2.cpython-312.pyc and b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson2.cpython-312.pyc differ diff --git a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson3.cpython-312.pyc b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson3.cpython-312.pyc index 1ad580aff..baf5dc600 100644 Binary files a/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson3.cpython-312.pyc and b/webpages/pythonx_lessons_pages/__pycache__/pythonx_lesson3.cpython-312.pyc differ diff --git a/webpages/testing.py b/webpages/testing.py index daf6b784f..f2f73bcf2 100644 --- a/webpages/testing.py +++ b/webpages/testing.py @@ -1,8 +1,54 @@ +import pandas as pd import streamlit as st -import subprocess +import requests +import folium +from streamlit_folium import folium_static +import sqlite3 +from datetime import datetime + from webpages import code_editor as ce +def get_ip(): + try: + response = requests.get('https://api.ipify.org') + return response.text + except: + return "Unable to get IP" + +def get_location(ip_address): + try: + response = requests.get(f'https://ipapi.co/{ip_address}/json/') + data = response.json() + return data['latitude'], data['longitude'], data['city'], data['country_name'] + except: + return None, None, "Unknown", "Unknown" + +def save_visitor(conn, lat, lon, city, country): + timestamp = datetime.now() + c = conn.cursor() + c.execute("INSERT INTO visitors (latitude, longitude, city, country, timestamp) VALUES (?, ?, ?, ?, ?)", + (lat, lon, city, country, timestamp)) + conn.commit() + +def get_all_visitors(conn): + df = pd.read_sql_query("SELECT * from visitors", conn) + return df + + + +def create_map(df): + m = folium.Map(location=[41.2706, -97.1749], zoom_start=4) + # Create a custom icon + + for _, row in df.iterrows(): + folium.Marker( + location = [row['latitude'], row['longitude']], + popup=f"{row['city']}", + tooltip=f"{row['city']}" + ).add_to(m) + return m + def testing(): st.title("Testing Page") # ce.code_editor() @@ -11,3 +57,55 @@ def testing(): # # video = "https://youtu.be/HluANRwPyNo?feature=shared" # # st.video(video) + + # Initialize the database + conn = sqlite3.connect('./files/visitor_locations.db') + c = conn.cursor() + c.execute('''CREATE TABLE IF NOT EXISTS visitors + (id INTEGER PRIMARY KEY AUTOINCREMENT, + latitude REAL, + longitude REAL, + city TEXT, + country TEXT, + timestamp DATETIME)''') + conn.commit() + + + + st.title('Visitor Location Tracker') + + # Get and save current visitor's location + ip = get_ip() + lat, lon, city, country = get_location(ip) + if lat and lon: + save_visitor(conn, lat, lon, city, country) + st.write(f"Your location: {city}, {country}") + else: + st.write("Unable to determine your location") + + # Display all visitors on a map + st.subheader('All Visitor Locations') + df = get_all_visitors(conn) + if not df.empty: + m = create_map(df) + folium_static(m) + else: + st.write("No visitor data available yet.") + + # Display visitor statistics + st.subheader('Visitor Statistics') + col_visitors, col_cities, col_countries = st.columns(3) + if not df.empty: + with col_visitors: + st.metric(label="Total visitors", value= df['id'].nunique()) + with col_cities: + st.metric(label="Total cities", value= df['city'].nunique()) + with col_countries: + st.metric(label="Total countries", value= df['country'].nunique()) + st.write("Top 5 cities:") + st.write(df['city'].value_counts().head()) + else: + st.write("No visitor data available yet.") + + # Close the database connection + conn.close() \ No newline at end of file