|
import streamlit as st |
|
import pandas as pd |
|
import io |
|
|
|
st.set_page_config(layout="wide") |
|
|
|
|
|
def load_city_data(city): |
|
file_path = f"{city.lower()}.json" |
|
return pd.read_json(file_path) |
|
|
|
|
|
def main(): |
|
|
|
|
|
with st.sidebar: |
|
st.header("Bereich wählen") |
|
bamberg = st.markdown(""" |
|
<style> |
|
.custom-button { |
|
background-color: #4CAF50; |
|
color: white; |
|
padding: 14px 20px; |
|
margin: 8px 0; |
|
border: none; |
|
cursor: pointer; |
|
width: 100%; |
|
} |
|
.custom-button:hover { |
|
opacity: 0.8; |
|
} |
|
</style> |
|
<button class="custom-button">Bamberg</button> |
|
""", unsafe_allow_html=True) |
|
bamberg1 = st.button("Bamberg1") |
|
coburg = st.button("Coburg") |
|
bad_kissingen = st.button("Kissingen") |
|
|
|
|
|
data = None |
|
if bamberg: |
|
data = load_city_data("Bamberg") |
|
st.subheader("Vereine in Bamberg") |
|
|
|
if coburg: |
|
data = load_city_data("Coburg") |
|
st.subheader("Vereine in Coburg") |
|
|
|
if bad_kissingen: |
|
data = load_city_data("Kissingen") |
|
st.success("Vereine in Bad Kissingen") |
|
|
|
if data is not None: |
|
|
|
col1, col2 = st.columns([3, 1]) |
|
with col1: |
|
st.dataframe(data, width=1500) |
|
with col2: |
|
|
|
excel_buffer = io.BytesIO() |
|
data.to_excel(excel_buffer, index=False) |
|
excel_buffer.seek(0) |
|
st.download_button( |
|
label="Download Excel", |
|
data=excel_buffer, |
|
file_name="data.xlsx", |
|
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
) |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|
|
|