|
1 | 1 | # coding=utf-8
|
2 | 2 | import streamlit as st
|
3 | 3 | import yaml
|
4 |
| -import session |
5 | 4 | import time
|
6 |
| - |
7 |
| -import pages.main as es |
8 |
| -import pages.about as ab |
9 |
| - |
| 5 | +from pages import inicio, inicio2 |
| 6 | +import pages.about as sobre |
| 7 | +import pages.passos as guiapassos |
| 8 | +import pages.simulacao as simulacao |
| 9 | +import pages.referencesContainer as referencias |
| 10 | +import pages.duvidas as duvidas |
| 11 | +import socket |
10 | 12 | import utils
|
11 | 13 | import pages.simulationContainer as sc
|
12 | 14 | from PIL import Image
|
| 15 | +import pathlib |
| 16 | +from flask import Flask, request |
| 17 | +from flask.wrappers import Request |
13 | 18 |
|
14 | 19 |
|
15 | 20 | st.set_page_config(
|
|
18 | 23 | layout='wide',
|
19 | 24 | initial_sidebar_state='collapsed')
|
20 | 25 |
|
| 26 | +# Remove menu da visualizacao |
| 27 | +hide_streamlit_style = """ |
| 28 | + <style> |
| 29 | + #MainMenu {visibility: hidden;} |
| 30 | + footer {visibility: hidden;} |
| 31 | + </style> |
| 32 | +
|
| 33 | + """ |
| 34 | +st.markdown(hide_streamlit_style, unsafe_allow_html=True) |
| 35 | + |
| 36 | +# # SESSION STATE |
| 37 | +# time.sleep( |
| 38 | +# 0.05 |
| 39 | +# ) # minimal wait time so we give time for the user session to appear in steamlit |
| 40 | +# session_state = session.SessionState.get( |
| 41 | +# key=session.get_user_id(), |
| 42 | +# update=False, |
| 43 | +# state_name="Acre", |
| 44 | +# state_id="AC", |
| 45 | +# city_name="Todos", |
| 46 | +# administrative_level="Todos", |
| 47 | +# refresh=False, |
| 48 | +# reset=False, |
| 49 | +# already_generated_user_id=None, |
| 50 | +# pages_open=None, |
| 51 | +# amplitude_events=None, |
| 52 | +# button_styles=dict(), |
| 53 | +# continuation_selection=None, |
| 54 | +# button_simule=0, |
| 55 | +# section1_organize=False, |
| 56 | +# section2_manage=False |
| 57 | +# ) |
| 58 | +# utils.applyButtonStyles(session_state) |
| 59 | +# PAGES[page].main(session_state) |
| 60 | +# # query_params = st.experimental_get_query_params() |
| 61 | +# # page_param = query_params.get("page", [0]) |
| 62 | +# # if query_params: |
| 63 | +# # PAGES[page_param[0]].main(session_state) |
| 64 | +# # else: |
| 65 | +# # PAGES[page].main(session_state) |
| 66 | + |
21 | 67 |
|
22 | 68 | def main():
|
23 | 69 | """
|
24 | 70 | This function generates Escola Segura
|
25 | 71 | """
|
26 | 72 |
|
27 |
| - # Remove menu da visualizacao |
28 |
| - hide_streamlit_style = """ |
29 |
| - <style> |
30 |
| - #MainMenu {visibility: hidden;} |
31 |
| - footer {visibility: hidden;} |
32 |
| - </style> |
33 |
| -
|
34 |
| - """ |
35 |
| - st.markdown(hide_streamlit_style, unsafe_allow_html=True) |
36 |
| - |
37 | 73 | # SESSION STATE
|
38 | 74 | time.sleep(
|
39 | 75 | 0.05
|
40 | 76 | ) # minimal wait time so we give time for the user session to appear in steamlit
|
41 |
| - session_state = session.SessionState.get( |
42 |
| - key=session.get_user_id(), |
43 |
| - update=False, |
44 |
| - state_name="Acre", |
45 |
| - state_id="AC", |
46 |
| - city_name="Todos", |
47 |
| - administrative_level="Todos", |
48 |
| - refresh=False, |
49 |
| - reset=False, |
50 |
| - already_generated_user_id=None, |
51 |
| - pages_open=None, |
52 |
| - amplitude_events=None, |
53 |
| - button_styles=dict(), |
54 |
| - continuation_selection=None, |
55 |
| - button_simule=0, |
56 |
| - section1_organize=False, |
57 |
| - section2_manage=False, |
58 |
| - ) |
59 |
| - |
60 |
| - PAGES = { |
61 |
| - "Escola Segura": es, |
62 |
| - "Quem somos?" : ab |
63 |
| - } |
64 |
| - |
65 |
| - page = st.sidebar.radio( |
66 |
| - "Menu", list(PAGES.keys()), |
67 |
| - ) |
68 | 77 |
|
69 |
| - if __name__ == "__main__": |
70 |
| - PAGES[page].main(session_state) |
71 |
| - utils.applyButtonStyles(session_state) |
| 78 | + PAGES = { |
| 79 | + "inicio" : inicio, |
| 80 | + "inicio2" : inicio2, |
| 81 | + "guia10passos" : guiapassos, |
| 82 | + "simulation" : simulacao, |
| 83 | + "sobre" : sobre, |
| 84 | + "referencias": referencias, |
| 85 | + "duvidasfrequentes" : duvidas |
| 86 | + } |
| 87 | + # page = st.sidebar.radio( |
| 88 | + # "Menu", list(PAGES.keys()), |
| 89 | + # ) |
| 90 | + query_params = st.experimental_get_query_params() |
| 91 | + page_param = query_params.get("page", [0]) |
| 92 | + if query_params: |
| 93 | + PAGES[page_param[0]].main() |
| 94 | + else: |
| 95 | + inicio.main() |
72 | 96 |
|
| 97 | + # if query_params: |
| 98 | + # PAGES[page_param[0]].main() |
| 99 | + # else: |
| 100 | + # PAGES[page].main() |
| 101 | + |
73 | 102 |
|
74 | 103 | if __name__ == "__main__":
|
75 | 104 | main()
|
| 105 | + |
| 106 | +# app = Flask(__name__) |
| 107 | + |
| 108 | +# @app.route('/') |
| 109 | +# def main(): |
| 110 | +# # # inicio.main() |
| 111 | +# return "Hello World!" |
| 112 | + |
| 113 | +# if __name__ == "__main__": |
| 114 | +# app.run(host="0.0.0.0", debug=True, port=8501) |
| 115 | +# # app.run(host="localhost", debug=True, port=8501) |
| 116 | + |
| 117 | + |
| 118 | +# from flask import Flask |
| 119 | +# app = Flask(__name__) |
| 120 | + |
| 121 | +# @app.route('/') |
| 122 | +# def main(): |
| 123 | +# return inicio.main() |
| 124 | + |
| 125 | +# @app.route('/<path:entry>') |
| 126 | +# def hello(entry): |
| 127 | +# if entry=='guia10passos': |
| 128 | +# return 'Guia Passos!' |
| 129 | +# elif entry=='simulador': |
| 130 | +# return 'Simulador!' |
| 131 | +# else: |
| 132 | +# return "Hello World!" |
| 133 | + |
| 134 | +# if __name__ == '__main__': |
| 135 | +# app.run() |
| 136 | + |
| 137 | +# x = st.slider('Pick a number') |
| 138 | +# st.write('You picked:', x) |
| 139 | + |
| 140 | +# if not hasattr(st, 'already_started_server'): |
| 141 | +# # Hack the fact that Python modules (like st) only load once to |
| 142 | +# # keep track of whether this file already ran. |
| 143 | +# st.already_started_server = True |
| 144 | + |
| 145 | +# st.write(''' |
| 146 | +# The first time this script executes it will run forever because it's |
| 147 | +# running a Flask server. |
| 148 | + |
| 149 | +# Just close this browser tab and open a new one to see your Streamlit |
| 150 | +# app. |
| 151 | +# ''') |
| 152 | + |
| 153 | +# from flask import Flask |
| 154 | + |
| 155 | +# app = Flask(__name__) |
| 156 | + |
| 157 | +# @app.route('/foo') |
| 158 | +# def serve_foo(): |
| 159 | +# x = st.slider('Pick a number') |
| 160 | +# st.write('You picked:', x) |
| 161 | +# return 'This page is served via Flask!' |
| 162 | + |
| 163 | +# app.run(port=8888) |
| 164 | + |
| 165 | + |
| 166 | +# # We'll never reach this part of the code the first time this file executes! |
| 167 | + |
| 168 | +# # Your normal Streamlit app goes here: |
| 169 | +# x = st.slider('Pick a number') |
| 170 | +# st.write('You picked:', x) |
0 commit comments