diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1e2d650 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,8 @@ +streamlit +google +pandas +numpy +pybase64 +seaborn +matplotlib +plotly \ No newline at end of file diff --git a/streamlit.py b/streamlit.py index f5a8340..256f8bd 100644 --- a/streamlit.py +++ b/streamlit.py @@ -1,13 +1,69 @@ import streamlit as st +import pandas as pandas +import numpy as np +import pybase64 as base64 +import seaborn as sns +import matplotlib.pypot as plt +import plotly.express as px + +## Début du display st.title('Water Tracker') +st.sidebar.title('Navigation') st.sidebar.radio('Indicateurs de niveaux d'eau', [":rainbow["Sècheresse"]", "Autre indicateur" , "Water Tracker:movie_camera:"]) -pages = ['page1', 'page2', 'page3'] +pages = ["Sècheresse", "Autre indicateur" , "Water Tracker"] + + +# connection = connection to db / addresse de files dans S3 (dispo sous url) +[gcp_service_account] +type = "service_account" +project_id = "xxx" +private_key_id = "xxx" +private_key = "xxx" +client_email = "xxx" +client_id = "xxx" +auth_uri = "https://accounts.google.com/o/oauth2/auth" +token_uri = "https://oauth2.googleapis.com/token" +auth_provider_x509_cert_url = "https://www.googleapis.com/oauth2/v1/certs" +client_x509_cert_url = "xxx" + +# streamlit_app.py + +import streamlit as st +from google.oauth2 import service_account +from google.cloud import bigquery + +# Create API client. +credentials = service_account.Credentials.from_service_account_info( + st.secrets["gcp_service_account"] +) +client = bigquery.Client(credentials=credentials) + +# Perform query. +# Uses st.cache_data to only rerun when the query changes or after 10 min. +@st.cache_data(ttl=600) +def run_query(query): + query_job = client.query(query) + rows_raw = query_job.result() + # Convert to list of dicts. Required for st.cache_data to hash the return value. + rows = [dict(row) for row in rows_raw] + return rows + +rows = run_query("SELECT word FROM `bigquery-public-data.samples.shakespeare` LIMIT 10") + +# Print results. +st.write("Some wise words from Shakespeare:") +for row in rows: + st.write("✍️ " + row['word']) -connection = connection to db / addresse de files dans S3 (dispo sous url) +#df = to_dataframe(data extracted from database) if page == pages[0]: #things to put on the page + fig, ax = plt.subplots() + ax.plot(df.x, df.y) + st.title('title') + st.pyplot(fig) if page == pages[1]: #things to put on the second page if page == pages[2]: