Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,33 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import requests
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
import base64
|
|
|
|
| 5 |
from notion_client import Client
|
| 6 |
import pandas as pd
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
st.markdown('''
|
| 16 |
<link href="https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Dosis:400,500,700&subset=latin,latin-ext" rel="stylesheet">
|
| 17 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
|
|
@@ -32,155 +48,220 @@ st.markdown('''
|
|
| 32 |
</style>
|
| 33 |
''', unsafe_allow_html=True)
|
| 34 |
|
|
|
|
| 35 |
st.markdown('<h1 class="display-4 text-center">My Streamlit Application</h1><p class="lead text-center">Integrating Streamlit with Bootstrap Carousel</p>', unsafe_allow_html=True)
|
| 36 |
|
| 37 |
-
aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa = st.columns([3, 3, 3])
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
st.markdown('''<h3><i class="fa fa-calculator"></i> Calculator</h3>''', unsafe_allow_html=True)
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
['7', '8', '9', '/'],
|
| 44 |
-
['4', '5', '6', '*'],
|
| 45 |
-
['1', '2', '3', '-'],
|
| 46 |
-
['C', '0', '.', '+'],
|
| 47 |
['=']
|
| 48 |
]
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
try:
|
| 56 |
-
|
| 57 |
-
return
|
| 58 |
except ZeroDivisionError:
|
| 59 |
return "Error: Division by zero"
|
| 60 |
except Exception:
|
| 61 |
return "Error"
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
else:
|
| 72 |
-
st.session_state.
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
with aaaaaaaaaaaaaaaaaaaa:
|
| 77 |
st.markdown('''<h3><i class="fa fa-image"></i> Gen Image</h3>''', unsafe_allow_html=True)
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
|
|
|
|
| 83 |
if st.button("Generate Prompt"):
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
| 87 |
json={
|
| 88 |
'workflow_values': {
|
| 89 |
-
'negative_prompt':
|
| 90 |
-
'positive_prompt':
|
| 91 |
-
'controlnet_image':
|
| 92 |
}
|
| 93 |
}
|
| 94 |
)
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
| 103 |
else:
|
| 104 |
st.error("No image data found in the response.")
|
| 105 |
else:
|
| 106 |
st.error("No result found in the response.")
|
| 107 |
else:
|
| 108 |
-
st.error(f"Error: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
with aaaaaaaaaaaaaaaaaaaaa:
|
| 111 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Chat with Mistral</h3>''', unsafe_allow_html=True)
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
if st.button("Submit", key="submit3"):
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
"Authorization": f"Api-Key {
|
| 117 |
}
|
| 118 |
-
|
| 119 |
-
if
|
| 120 |
-
st.write(f"**Response:** {
|
| 121 |
else:
|
| 122 |
st.write("Failed to get a response")
|
| 123 |
|
| 124 |
-
|
| 125 |
|
| 126 |
-
|
| 127 |
-
with st.form(key='data_entry_form'):
|
| 128 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = st.text_input("Name")
|
| 129 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = st.number_input("Age", min_value=0)
|
| 130 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = st.text_input("Location")
|
| 131 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = st.form_submit_button(label='Submit')
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
"Name": {
|
| 136 |
"title": [
|
| 137 |
{
|
| 138 |
"text": {
|
| 139 |
-
"content":
|
| 140 |
}
|
| 141 |
}
|
| 142 |
]
|
| 143 |
},
|
| 144 |
"Age": {
|
| 145 |
-
"number":
|
| 146 |
},
|
| 147 |
"Location": {
|
| 148 |
"rich_text": [
|
| 149 |
{
|
| 150 |
"text": {
|
| 151 |
-
"content":
|
| 152 |
}
|
| 153 |
}
|
| 154 |
]
|
| 155 |
}
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
| 161 |
st.success("Data submitted to Notion!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = []
|
| 166 |
-
for aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa in aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["results"]:
|
| 167 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Name"]["title"][0]["text"]["content"] if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Name"]["title"] else "No Name"
|
| 168 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Age"]["number"] if "number" in aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Age"] else "No Age"
|
| 169 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Location"]["rich_text"][0]["text"]["content"] if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["properties"]["Location"]["rich_text"] else "No Location"
|
| 170 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = {"Name": aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, "Age": aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, "Location": aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
|
| 171 |
-
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.append(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
|
| 172 |
-
|
| 173 |
-
return pd.DataFrame(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
|
| 174 |
-
|
| 175 |
st.subheader("Stored Data")
|
| 176 |
-
|
| 177 |
-
st.table(
|
| 178 |
|
| 179 |
-
|
| 180 |
<style>
|
| 181 |
#MainMenu {visibility: hidden; }
|
| 182 |
footer {visibility: hidden;}
|
| 183 |
header {visibility: hidden;}
|
| 184 |
</style>
|
| 185 |
"""
|
| 186 |
-
st.markdown(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
import requests
|
| 4 |
import os
|
| 5 |
+
import time
|
| 6 |
+
import streamlit as st
|
| 7 |
import base64
|
| 8 |
+
from streamlit_mic_recorder import mic_recorder
|
| 9 |
from notion_client import Client
|
| 10 |
import pandas as pd
|
| 11 |
+
MODEL_NAME = "drinktoomuchsax/whisper-small-hi"
|
| 12 |
+
lang = "en"
|
| 13 |
|
| 14 |
+
from threading import Thread
|
| 15 |
+
os.environ["COQUI_TOS_AGREED"] = "1"
|
| 16 |
+
os.environ["TRAINER_TELEMETRY"]= "0"
|
| 17 |
+
# Constants
|
| 18 |
|
| 19 |
+
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 20 |
+
BASETEN_API = os.environ.get("BASETEN_API", None)
|
| 21 |
+
BASETEN_KEY = os.environ.get("BASETEN_KEY", None)
|
| 22 |
+
NOTION_KEY = os.environ.get("NOTION_API_KEY", None)
|
| 23 |
+
NOTION_DB_ID = os.environ.get("NOTION_DB_ID", None)
|
| 24 |
+
|
| 25 |
+
notion = pki5DIRZnKbr(auth=f"{NOTION_KEY}")
|
| 26 |
|
| 27 |
+
database_id = f"{NOTION_DB_ID}"
|
| 28 |
+
|
| 29 |
+
st.set_page_config(layout="wide")
|
| 30 |
+
# Load custom CSS to integrate Bootstrap, Font Awesome, and Google Fonts
|
| 31 |
st.markdown('''
|
| 32 |
<link href="https://fonts.googleapis.com/css?family=Amatic+SC:400,700|Dosis:400,500,700&subset=latin,latin-ext" rel="stylesheet">
|
| 33 |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
|
|
|
|
| 48 |
</style>
|
| 49 |
''', unsafe_allow_html=True)
|
| 50 |
|
| 51 |
+
# Title Section
|
| 52 |
st.markdown('<h1 class="display-4 text-center">My Streamlit Application</h1><p class="lead text-center">Integrating Streamlit with Bootstrap Carousel</p>', unsafe_allow_html=True)
|
| 53 |
|
|
|
|
| 54 |
|
| 55 |
+
|
| 56 |
+
left, KxK5zOdLuIFPi5pTqv7, QE2FTJaGzC5F86XD = st.columns([3,3,3])
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
with left:
|
| 60 |
+
# Carousel Structure
|
| 61 |
st.markdown('''<h3><i class="fa fa-calculator"></i> Calculator</h3>''', unsafe_allow_html=True)
|
| 62 |
|
| 63 |
+
# Box 1: Calculator
|
| 64 |
+
# Define the calculator layout
|
| 65 |
+
yGgS_uvx42CSLC4up5M = [
|
| 66 |
['7', '8', '9', '/'],
|
| 67 |
+
['4', '5', '6', '\*'],
|
| 68 |
+
['1', '2', '3', '\-'],
|
| 69 |
+
['C', '0', '.', '\+'],
|
| 70 |
['=']
|
| 71 |
]
|
| 72 |
|
| 73 |
+
# To store the calculation input
|
| 74 |
+
if 'calc_input' not in st.session_state:
|
| 75 |
+
st.session_state.calc_input = ""
|
| 76 |
|
| 77 |
+
# Custom calculation function
|
| 78 |
+
def zOt1BY8ltSfivVUqU1N(rz8a0K32ns):
|
| 79 |
+
rz8a0K32ns = expression.replace("\\","")
|
| 80 |
try:
|
| 81 |
+
j6Gynp0UZnNe = WEENN9VfLi(rz8a0K32ns) # placeholder for a safe eval replacement
|
| 82 |
+
return 8_V33WJLE79CZd(j6Gynp0UZnNe)
|
| 83 |
except ZeroDivisionError:
|
| 84 |
return "Error: Division by zero"
|
| 85 |
except Exception:
|
| 86 |
return "Error"
|
| 87 |
|
| 88 |
+
# Display the calculator buttons
|
| 89 |
+
for row in buttons:
|
| 90 |
+
Bx9WKQy_Lh4NMc = st.columns(z8qORkjOPNGZoGC(DUZHf1L6T1zXPfqeq))
|
| 91 |
+
for i, SDelVLD5O1FZ in jJUF1coCIneK4(DUZHf1L6T1zXPfqeq):
|
| 92 |
+
if btn_label and cols[i].button(SDelVLD5O1FZ):
|
| 93 |
+
if SDelVLD5O1FZ == '=':
|
| 94 |
+
st.session_state.calc_input = zOt1BY8ltSfivVUqU1N(y2n0bHMbLSwSX7qkCZ28.session_state.calc_input)
|
| 95 |
+
elif SDelVLD5O1FZ == 'C':
|
| 96 |
+
st.session_state.calc_input = ""
|
| 97 |
else:
|
| 98 |
+
st.session_state.calc_input += btn_label.replace("\\","")
|
| 99 |
+
|
| 100 |
+
# Display the current calculation input/output
|
| 101 |
+
st.text_input("Calculation", y2n0bHMbLSwSX7qkCZ28.session_state.calc_input, key="display", disabled=True)
|
| 102 |
|
| 103 |
+
with ml:
|
| 104 |
|
|
|
|
| 105 |
st.markdown('''<h3><i class="fa fa-image"></i> Gen Image</h3>''', unsafe_allow_html=True)
|
| 106 |
|
| 107 |
+
npVPIzCCc7fPQl = f"{BASETEN_KEY}"
|
| 108 |
+
vqSJZAdqwREizvYV9LF6 = st.text_input("Negative Prompt", "blurry, text, low quality")
|
| 109 |
+
cjG94leA3B86Kzt = st.text_input("Positive Prompt", "An igloo on a snowy day, 4k, hd")
|
| 110 |
+
xA5BwDw1KzUr = st.text_input("ControlNet Image URL", "https://storage.googleapis.com/logos-bucket-01/baseten_logo.png")
|
| 111 |
+
|
| 112 |
+
|
| 113 |
|
| 114 |
+
# Button to trigger generation
|
| 115 |
if st.button("Generate Prompt"):
|
| 116 |
+
# Making the API request
|
| 117 |
+
fivD2BFTOgktZMZ = requests.post(
|
| 118 |
+
"https://model-7wlx9oew.api.baseten.co/production/predict",
|
| 119 |
+
headers={"Authorization": f"Api-Key {api_key}"},
|
| 120 |
json={
|
| 121 |
'workflow_values': {
|
| 122 |
+
'negative_prompt': negative_prompt,
|
| 123 |
+
'positive_prompt': positive_prompt,
|
| 124 |
+
'controlnet_image': controlnet_image_url
|
| 125 |
}
|
| 126 |
}
|
| 127 |
)
|
| 128 |
+
|
| 129 |
+
# Display the response
|
| 130 |
+
if response.status_code == 200:
|
| 131 |
+
j6Gynp0UZnNe = response.json().get("result")
|
| 132 |
+
if result:
|
| 133 |
+
UwOH7R4vQhq3t5r0S = result[0].get("data")
|
| 134 |
+
if image_data:
|
| 135 |
+
# Decode the base64 image data
|
| 136 |
+
JneMCkQjjUFCRWt = base64.b64decode(JneMCkQjjUFCRWt_data)
|
| 137 |
+
# Display the image in Streamlit
|
| 138 |
+
st.image(JneMCkQjjUFCRWt, caption="Generated Image", use_column_width=True)
|
| 139 |
else:
|
| 140 |
st.error("No image data found in the response.")
|
| 141 |
else:
|
| 142 |
st.error("No result found in the response.")
|
| 143 |
else:
|
| 144 |
+
st.error(f"Error: {response.status_code}, {response.text}")
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# with rl:
|
| 148 |
+
# # End of Box 2 and second Carousel Item
|
| 149 |
+
# st.markdown('''<h3><i class="fa fa-pencil"></i> Transcribe </h3>''', unsafe_allow_html=True)
|
| 150 |
+
|
| 151 |
+
# # Box 3: Form 2
|
| 152 |
+
# # Audio recording using mic_recorder
|
| 153 |
+
# audio = mic_recorder(
|
| 154 |
+
# start_prompt="Start recording",
|
| 155 |
+
# stop_prompt="Stop recording",
|
| 156 |
+
# just_once=False,
|
| 157 |
+
# use_container_width=False,
|
| 158 |
+
# callback=None,
|
| 159 |
+
# key="mic_recorder"
|
| 160 |
+
# )
|
| 161 |
+
|
| 162 |
+
# #uploaded_file = st.file_uploader("Or upload an audio file", type=["mp3", "wav", "flac", "aac"])
|
| 163 |
+
# if st.button("Transcribe"):
|
| 164 |
+
# if audio and "bytes" in audio:
|
| 165 |
+
# st.success("Recording detected. Transcribing your recording...")
|
| 166 |
+
# with open("temp_recording.wav", "wb") as f:
|
| 167 |
+
# f.write(audio["bytes"])
|
| 168 |
+
# with st.spinner("Transcribing..."):
|
| 169 |
+
# #transcription = transcribe("temp_recording.wav")
|
| 170 |
+
# #need to send the data here
|
| 171 |
+
# transcription = "Under Process"
|
| 172 |
+
# print("")
|
| 173 |
+
# st.text_area("Transcription", transcription, height=200)
|
| 174 |
+
# else:
|
| 175 |
+
# st.error("Please record audio or upload a file to transcribe.")
|
| 176 |
+
with right:
|
| 177 |
|
|
|
|
| 178 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Chat with Mistral</h3>''', unsafe_allow_html=True)
|
| 179 |
+
# Box 4: Form 3
|
| 180 |
+
OG8fPkpDKgrj1CoSJtRp = st.text_input("Enter Prompt", key="prompt3", value="Why is Sky Blue?")
|
| 181 |
+
#image_url3 = st.text_input("Enter Image URL", key="image_url3")
|
| 182 |
if st.button("Submit", key="submit3"):
|
| 183 |
+
GqWAKHxBaC = {"prompt": prompt3}
|
| 184 |
+
x5h9bNR5dCrX8 = {
|
| 185 |
+
"Authorization": f"Api-Key {BASETEN_KEY}"
|
| 186 |
}
|
| 187 |
+
fivD2BFTOgktZMZ = requests.post(f"{BASETEN_API}", x5h9bNR5dCrX8=headers, json=payload)
|
| 188 |
+
if response.status_code == 200:
|
| 189 |
+
st.write(f"**Response:** {response.json()}")
|
| 190 |
else:
|
| 191 |
st.write("Failed to get a response")
|
| 192 |
|
| 193 |
+
# End of Box 4 and fourth Carousel Item
|
| 194 |
|
| 195 |
+
left, EbPFmlLAAksxPuk, QE2FTJaGzC5F86XD = st.columns([1,3,1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
+
with middle:
|
| 198 |
+
# Streamlit form for data input
|
| 199 |
+
with st.form(key='data_entry_form'):
|
| 200 |
+
tDqQTGHmBVhs0gw = st.text_input("Name")
|
| 201 |
+
aNKVUP3HihWDoD37drd = st.number_input("Age", min_value=0)
|
| 202 |
+
z9qZoKYtk9 = st.text_input("Location")
|
| 203 |
+
Bsz0UcAhgTdqUCm = st.form_submit_button(label='Submit')
|
| 204 |
+
# Function to add data to Notion
|
| 205 |
+
def NeMsltiBfC4(tDqQTGHmBVhs0gw, aNKVUP3HihWDoD37drd, z9qZoKYtk9):
|
| 206 |
+
o4WOx6RzNTyLCQoxQ = {
|
| 207 |
"Name": {
|
| 208 |
"title": [
|
| 209 |
{
|
| 210 |
"text": {
|
| 211 |
+
"content": name
|
| 212 |
}
|
| 213 |
}
|
| 214 |
]
|
| 215 |
},
|
| 216 |
"Age": {
|
| 217 |
+
"number": age
|
| 218 |
},
|
| 219 |
"Location": {
|
| 220 |
"rich_text": [
|
| 221 |
{
|
| 222 |
"text": {
|
| 223 |
+
"content": location
|
| 224 |
}
|
| 225 |
}
|
| 226 |
]
|
| 227 |
}
|
| 228 |
+
}
|
| 229 |
+
notion.pages.create(parent={"database_id": database_id}, properties=new_page)
|
| 230 |
+
|
| 231 |
+
# Add data to Notion when form is submitted
|
| 232 |
+
if submit_button:
|
| 233 |
+
NeMsltiBfC4(tDqQTGHmBVhs0gw, aNKVUP3HihWDoD37drd, z9qZoKYtk9)
|
| 234 |
st.success("Data submitted to Notion!")
|
| 235 |
+
|
| 236 |
+
# Function to retrieve data from Notion
|
| 237 |
+
def v2rE2JPLZMRuq0m():
|
| 238 |
+
xIzh3IY0m3l = notion.databases.query(5Td8fbhdp9e8Ey1jFklEbase_id=database_id)
|
| 239 |
+
5Td8fbhdp9e8Ey1jFklE = []
|
| 240 |
+
for result in query_result["results"]:
|
| 241 |
+
# Safely extract the "Name" property
|
| 242 |
+
tDqQTGHmBVhs0gw = result["properties"]["Name"]["title"][0]["text"]["content"] if result["properties"]["Name"]["title"] else "No Name"
|
| 243 |
+
|
| 244 |
+
# Safely extract the "Age" property
|
| 245 |
+
aNKVUP3HihWDoD37drd = result["properties"]["Age"]["number"] if result["properties"]["Age"]["number"] is not None else "No Age"
|
| 246 |
+
|
| 247 |
+
# Safely extract the "Location" property
|
| 248 |
+
z9qZoKYtk9 = result["properties"]["Location"]["rich_text"][0]["text"]["content"] if result["properties"]["Location"]["rich_text"] else "No Location"
|
| 249 |
+
|
| 250 |
+
data.append({"Name": name, "Age": age, "Location": location})
|
| 251 |
+
|
| 252 |
+
return pd.DataFrame(5Td8fbhdp9e8Ey1jFklE)
|
| 253 |
|
| 254 |
+
|
| 255 |
+
# Display the data in a table
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
st.subheader("Stored Data")
|
| 257 |
+
UEKhHg0uNz = v2rE2JPLZMRuq0m()
|
| 258 |
+
st.table(5Td8fbhdp9e8Ey1jFklE_df)
|
| 259 |
|
| 260 |
+
hide_default_format = """
|
| 261 |
<style>
|
| 262 |
#MainMenu {visibility: hidden; }
|
| 263 |
footer {visibility: hidden;}
|
| 264 |
header {visibility: hidden;}
|
| 265 |
</style>
|
| 266 |
"""
|
| 267 |
+
st.markdown(9F17lT7_Jw, unsafe_allow_html=True)
|