Spaces:
Sleeping
Sleeping
Commit
·
726778d
1
Parent(s):
dc19f53
Update app.py
Browse files
app.py
CHANGED
@@ -4,34 +4,36 @@ import random
|
|
4 |
import pandas as pd
|
5 |
import streamlit as st
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
df = pd.DataFrame.from_dict(recipe_list)
|
33 |
-
st.dataframe(
|
34 |
-
df,
|
35 |
-
column_config={"url": st.column_config.LinkColumn()},
|
36 |
-
hide_index=True,
|
37 |
-
)
|
|
|
4 |
import pandas as pd
|
5 |
import streamlit as st
|
6 |
|
7 |
+
with st.form("my_form"):
|
8 |
+
n_recipes = st.slider('Select number of recipes to get', 0, 20, 1)
|
9 |
+
submitted = st.form_submit_button("Submit")
|
10 |
+
url = "https://api.notion.com/v1/databases/180f4b492f4d421c88028c54cfe077a5/query"
|
11 |
+
payload = json.dumps({
|
12 |
+
"filter": {
|
13 |
+
"property": "Weekly Rotation",
|
14 |
+
"checkbox": {
|
15 |
+
"equals": True
|
16 |
+
}
|
17 |
+
}
|
18 |
+
})
|
19 |
+
headers = {
|
20 |
+
'Authorization': 'Bearer secret_oG3PIzAL10np4NadmID4X93ISNJP7zHBr6CQ8Oskakb',
|
21 |
+
'Content-Type': 'application/json',
|
22 |
+
'Notion-Version': '2022-02-22'
|
23 |
}
|
24 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
25 |
+
recipes = response.json()
|
26 |
+
|
27 |
+
recipe_list = []
|
28 |
+
for recipe in random.sample(recipes['results'], n_recipes):
|
29 |
+
recipe_dict = {}
|
30 |
+
recipe_dict['name'] = recipe["properties"]["Name"]["title"][0]["plain_text"].strip()
|
31 |
+
recipe_dict['url'] = recipe["url"]
|
32 |
+
recipe_list.append(recipe_dict)
|
33 |
+
|
34 |
+
df = pd.DataFrame.from_dict(recipe_list)
|
35 |
+
st.dataframe(
|
36 |
+
df,
|
37 |
+
column_config={"url": st.column_config.LinkColumn()},
|
38 |
+
hide_index=True,
|
39 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|