コード例 #1
0
    def __init__(self):

        session_state = get(
            app_config=False,
            login_info={'password': ""},
            cur_page_idx=0,
        )

        self.login_info = session_state.login_info
        self.create_pages()
        self.create_side_bar()

        self.pages_dict = {page.name: page for page in self.pages}
        self.page_names = [page.name for page in self.pages]
        self.page_titles = [page.title for page in self.pages]

        self.cur_page = self.pages[session_state.cur_page_idx]
        self.cur_page_title = self.page_titles[session_state.cur_page_idx]
        self.cur_page_idx = session_state.cur_page_idx

        if session_state.app_config:
            self.load_config(session_state.app_config)
        else:
            self.start()

        self.render()
        session_state.app_config = self.get_config()
        session_state.login_info = self.login_info
        session_state.cur_page_idx = self.cur_page_idx
コード例 #2
0
 def __init__(self):
     self.state = get(firebase=None,
                      auth=None,
                      db=None,
                      loggedIn=False,
                      user=None,
                      fName=None)
     self._connect_to_api()
コード例 #3
0
def check_password():
    session_state = get(password='')

    if session_state.password != str(PWD):
        pwd_placeholder = st.sidebar.empty()
        pwd = pwd_placeholder.text_input("Password:"******"",
                                         type="password")
        session_state.password = pwd
        if session_state.password == str(PWD):
            pwd_placeholder.empty()
            return True
        elif session_state.password != '':
            st.error("the password you entered is incorrect")
            return False
    else:
        return True
コード例 #4
0
ファイル: utils.py プロジェクト: CFabian88/pure-solutions
def authenticate(url='http://heroku.com'):
    client = GoogleOAuth2(client_id, client_secret)
    authorization_url = asyncio.run(
        write_authorization_url(client=client, redirect_uri=redirect_uri))
    session_state = get(token=None)
    if session_state.token is None:
        try:
            code = st.experimental_get_query_params()['code']
        except:
            st.write(f'''
                <h1>
                Please login here: <a target="_self"
                href="{authorization_url}">Login</a></h1>
                ''',
                     unsafe_allow_html=True)
        else:
            try:
                token = asyncio.run(
                    write_access_token(client=client,
                                       redirect_uri=redirect_uri,
                                       code=code))
            except:
                st.write(f'''
                    <h1>
                    This account is not allowed or page was refreshed.
                    Please try again: <a target="_self"
                    href="{authorization_url}">Login</a></h1>
                    ''',
                         unsafe_allow_html=True)
            else:
                if token.is_expired():
                    if token.is_expired():
                        st.write(f'''<h1>
                            Login session has ended, please log in again: <a target="_self" 
                            href="{authorization_url}">Login</a></h1>
                            ''')
                else:
                    session_state.token = token
                    initialize()
    else:
        initialize()
コード例 #5
0
                su.post_matches(my_session, my_user_df, match_df,
                                my_channel_id)

                st.write("Updating history.")
                su.update_history(match_df, my_history_file)

            st.write("Done!")
            st.write("Thanks for using Bagel Bot! Goodbye!")

        else:
            st.write("Please select a channel!")


if __name__ == '__main__':

    session_state = get(password='')

    if session_state.password != 'T0p_S3cr3t':
        pwd_placeholder = st.sidebar.empty()
        pwd = pwd_placeholder.text_input("Password:"******"",
                                         type="password")
        session_state.password = pwd
        if session_state.password == 'pwd123':
            pwd_placeholder.empty()
            main()
        elif session_state.password != '':
            st.error("the password you entered is incorrect")
    else:
        main()
コード例 #6
0
import altair as alt
import pandas as pd
import requests
from SessionState import get

import streamlit as st

session_state = get(token='')


def get_played_tracks(token):
    response = requests.get('http://localhost:8000/user/played-tracks',
                            headers={
                                'Content-Type': 'accept: application/json',
                                'Authorization': f'Bearer {token}'
                            })
    played_tracks = response.json()
    played_tracks = pd.DataFrame(played_tracks)
    played_tracks['track'] = played_tracks['track'].apply(
        lambda x: x.get('name'))
    return played_tracks


def get_tracks(token):
    response = requests.get('http://localhost:8000/user/tracks',
                            headers={
                                'Content-Type': 'accept: application/json',
                                'Authorization': f'Bearer {token}'
                            })
    tracks = response.json()
    tracks = pd.DataFrame(tracks)
コード例 #7
0

def get_input_img():
    uploaded_file = st.file_uploader("Choose a file", type=['png', 'jpg'])

    if uploaded_file:
        pos = Image.open(uploaded_file)
        cols = st.beta_columns(5)
        with cols[2]:
            st.image(pos, use_column_width=True)
    return uploaded_file


# STREAMLIT PAGE
params = {'get_prediction': False, 'file_name': ''}
session_state = get(**params)
'''
# The Posture Wizard
'''
st.markdown(
    """ Find the best exercises to fix your upper body part posture """)

st.markdown("""
            - Upload a side picture of yourself
            - Our wizard will then determine your posture
            - Finally you will be suggested exercises based on your posture
            """)
st.markdown(""" # Step One """)
st.markdown("""Upload a side view of your posture""")

uploaded_file = get_input_img()
コード例 #8
0
ファイル: streamlit.py プロジェクト: billboardcat/sos9
import streamlit as st
import os
import pandas as pd
from SessionState import get
from PIL import Image


session_state = get(username='', password='', is_active=False)
default_pwd = "123"


def main():
    st.subheader("Hello, " + session_state.username + "! :smile:")
    st.info("Get started by answering some questions about your course in the sidebar")
    st.sidebar.header("Step 1 - Upload your student data:")
    file = st.sidebar.file_uploader("Upload a CSV file, max 200 MB", type='csv')
    if file is not None:
        my_DF = pd.read_csv(file)
        st.write(my_DF)

    st.sidebar.header("Step 2 - Tell us more about your course's structure:")

    # Yes/No questions, some will prompt for more information
    graded_attendance = st.sidebar.checkbox(label='Graded attendance')
    lecture_online = st.sidebar.checkbox(label='Lecture materials are uploaded')
    supp_readings = st.sidebar.checkbox(label='Supplemental readings available')
    practice_exams = st.sidebar.checkbox(label='Practice exams available')
    course_calendar = st.sidebar.checkbox(label='Course calendar available')

    lecture_quizzes = st.sidebar.checkbox(label='In-class quizzes')
    quiz_count = 0 if not lecture_quizzes else st.sidebar.number_input(label="Quiz count", min_value=1)
コード例 #9
0
import streamlit as st
from datetime import date
#from session_state import get_state
import pandas as pd
import yfinance as yf
from fbprophet import Prophet
from fbprophet.plot import plot_plotly, plot_components_plotly
from plotly import graph_objs as go
#from streamlit.script_request_queue import RerunData
#from streamlit.script_runner import RerunException
from SessionState import get

empty_df = pd.DataFrame(
    columns=['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'])
session_state = get(data=empty_df,
                    prediction_years=1,
                    fitted_m='',
                    stock_name='None')

st.set_page_config(
    page_icon="🧊",
    layout="wide",
)

START = "2015-01-01"
TODAY = date.today().strftime("%Y-%m-%d")

st.title('NIFTY 100 Stocks Price Forecast App')

list_df = pd.read_csv('ind_nifty100list.csv')
kk = list_df['Symbol']
new_list = list()