Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
from notion_client import Client
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
notion = Client(auth=os.environ["NOTION_API_KEY"])
|
9 |
+
|
10 |
+
page_id = '09f9593420644b33a610079ff12458e0'
|
11 |
+
|
12 |
+
def fetch_notion_content():
|
13 |
+
response = notion.blocks.children.list(block_id=page_id)
|
14 |
+
return response['results']
|
15 |
+
|
16 |
+
def display_notion_content():
|
17 |
+
st.title("Notion Page Content")
|
18 |
+
|
19 |
+
blocks = fetch_notion_content()
|
20 |
+
|
21 |
+
for block in blocks:
|
22 |
+
if block['type'] == 'callout':
|
23 |
+
text_content = ''.join([text['plain_text'] for text in block['callout']['rich_text']])
|
24 |
+
st.info(f"Callout: {text_content}")
|
25 |
+
elif block['type'] == 'child_database':
|
26 |
+
st.subheader(f"Child Database: {block['child_database']['title']}")
|
27 |
+
else:
|
28 |
+
st.write(f"Unknown block type: {block['type']}")
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
display_notion_content()
|