Spaces:
Sleeping
Sleeping
Commit
·
4ef3b48
1
Parent(s):
ce889fc
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import requests
|
2 |
import json
|
3 |
import random
|
|
|
4 |
|
5 |
url = "https://api.notion.com/v1/databases/180f4b492f4d421c88028c54cfe077a5/query"
|
6 |
|
@@ -20,6 +21,12 @@ headers = {
|
|
20 |
response = requests.request("POST", url, headers=headers, data=payload)
|
21 |
recipes = response.json()
|
22 |
n_recipes = 10
|
|
|
23 |
for recipe in random.sample(recipes['results'], n_recipes):
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import requests
|
2 |
import json
|
3 |
import random
|
4 |
+
import pandas as pd
|
5 |
|
6 |
url = "https://api.notion.com/v1/databases/180f4b492f4d421c88028c54cfe077a5/query"
|
7 |
|
|
|
21 |
response = requests.request("POST", url, headers=headers, data=payload)
|
22 |
recipes = response.json()
|
23 |
n_recipes = 10
|
24 |
+
recipe_list = []
|
25 |
for recipe in random.sample(recipes['results'], n_recipes):
|
26 |
+
recipe_dict = {}
|
27 |
+
recipe_dict['name'] = recipe["properties"]["Name"]["title"][0]["plain_text"].strip()
|
28 |
+
recipe_dict['url'] = recipe["url"]
|
29 |
+
recipe_list.append(recipe_dict)
|
30 |
+
|
31 |
+
df = pd.DataFrame.from_dict(recipe_list)
|
32 |
+
st.dataframe(df)
|