Download app.py from DAM20/Etmam: direct link, hf CLI and curl.
- Browser
- Download file 3.11 kB
-
https://huggingface.co/spaces/DAM20/Etmam/resolve/main/app.py
- Command line
-
hf download hf://spaces/DAM20/Etmam/app.py
-
curl -L -o app.py https://huggingface.co/spaces/DAM20/Etmam/resolve/main/app.py
3.11 kB
| # -*- coding: utf-8 -*- | |
| from __future__ import annotations | |
| from datetime import datetime, date, time | |
| import pandas as pd | |
| import streamlit as st | |
| from analysis import read_excel_safe, build, get_pivots_for_ppt | |
| from ppt_fill import fill_ppt | |
| st.set_page_config(page_title="Reports 940", layout="centered") | |
| VISION_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/vision2030_logo.png" | |
| AMANAH_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/amanah_logo.png" | |
| CENTER_URL = "https://huggingface.co/spaces/DAM20/Etmam/resolve/main/assets/center_logo.png" | |
| page_css = """ | |
| <style> | |
| .stAppViewContainer { | |
| position: relative; | |
| background: linear-gradient(to bottom, #043548 0%, #02141e 55%, #01080c 100%); | |
| background-attachment: fixed; | |
| } | |
| main .block-container { | |
| max-width: 900px; | |
| padding-top: 2rem !important; | |
| } | |
| [data-testid="stHeader"] { | |
| background-color: rgba(0, 0, 0, 0); | |
| } | |
| .top-logos-wrapper { | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| margin-bottom: 1.2rem; | |
| } | |
| .vision-logo { | |
| width: 280px; | |
| height: auto; | |
| } | |
| .bottom-logos-row { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| column-gap: 25px; | |
| margin-top: -5px; | |
| } | |
| .center-logo { | |
| width: 270px; | |
| height: auto; | |
| } | |
| .amanah-logo { | |
| width: 200px; | |
| height: auto; | |
| } | |
| h1 { | |
| margin-top: 0.5rem !important; | |
| color: white !important; | |
| } | |
| label, p, span { | |
| color: white !important; | |
| } | |
| </style> | |
| """ | |
| st.markdown(page_css, unsafe_allow_html=True) | |
| st.markdown( | |
| f""" | |
| <div class="top-logos-wrapper"> | |
| <img src="{VISION_URL}" class="vision-logo" /> | |
| <div class="bottom-logos-row"> | |
| <img src="{CENTER_URL}" class="center-logo" /> | |
| <img src="{AMANAH_URL}" class="amanah-logo" /> | |
| </div> | |
| </div> | |
| """, | |
| unsafe_allow_html=True, | |
| ) | |
| st.markdown("<h1>Reports 940</h1>", unsafe_allow_html=True) | |
| uploaded_file = st.file_uploader("Upload file (Excel)", type=["xlsx"]) | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| d_closed = st.date_input("Date", value=date.today()) | |
| with col2: | |
| t_closed = st.time_input("Time", value=time(8, 0)) | |
| CLOSED_DT = pd.Timestamp(datetime.combine(d_closed, t_closed)) | |
| if uploaded_file is not None: | |
| df0 = read_excel_safe(uploaded_file) | |
| out_excel = build(df0, CLOSED_DT) | |
| p_open_ar, p_sla_ar, p_urbi = get_pivots_for_ppt(df0, CLOSED_DT) | |
| ppt_template = "templates/balady_template.pptx" | |
| out_ppt = fill_ppt(ppt_template, p_open_ar, p_sla_ar, p_urbi, CLOSED_DT) | |
| dl1, dl2 = st.columns(2) | |
| with dl1: | |
| st.download_button( | |
| "Download Excel report", | |
| data=out_excel.getvalue(), | |
| file_name="report_balady.xlsx", | |
| mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | |
| ) | |
| with dl2: | |
| st.download_button( | |
| "Download PowerPoint", | |
| data=out_ppt.getvalue(), | |
| file_name="report_balady.pptx", | |
| mime="application/vnd.openxmlformats-officedocument.presentationml.presentation", | |
| ) |