From c7842b62176c4d5d368efe1a5288560a886e7f26 Mon Sep 17 00:00:00 2001 From: pranjal-joshi Date: Sun, 8 Oct 2023 10:42:05 +0530 Subject: [PATCH] wip - download results button added, Docker DNS changed to 8.8.8.8 --- Dockerfile | 2 ++ src/streamlit_app.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c2ba423d..a7342bf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf + ENV LANG C.UTF-8 ADD . /opt/program/ diff --git a/src/streamlit_app.py b/src/streamlit_app.py index 22cfaa7f..e26b7c48 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -4,6 +4,7 @@ import os import configparser import urllib +import datetime from time import sleep from pathlib import Path from threading import Thread @@ -41,7 +42,16 @@ def check_updates(): def show_df_as_result_table(): try: df = pd.read_pickle('last_screened_unformatted_results.pkl') - st.markdown(f'#### 🔍 Found {len(df)} Results') + ac, bc = st.columns([6,1]) + ac.markdown(f'#### 🔍 Found {len(df)} Results') + bc.download_button( + label="Download Results", + data=df.to_csv().encode('utf-8'), + file_name=f'screenipy_results_{datetime.datetime.now().strftime("%H:%M:%S_%d-%m-%Y")}.csv', + mime='text/csv', + type='secondary', + use_container_width=True + ) df.index = df.index.map(lambda x: "https://in.tradingview.com/chart?symbol=NSE%3A" + x) df.index = df.index.map(lambda x: f'{x.split("%3A")[-1]}') df['Stock'] = df.index