Spaces:
Sleeping
Sleeping
Commit
·
ce889fc
1
Parent(s):
e73e9d8
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
import random
|
4 |
+
|
5 |
+
url = "https://api.notion.com/v1/databases/180f4b492f4d421c88028c54cfe077a5/query"
|
6 |
+
|
7 |
+
payload = json.dumps({
|
8 |
+
"filter": {
|
9 |
+
"property": "Weekly Rotation",
|
10 |
+
"checkbox": {
|
11 |
+
"equals": True
|
12 |
+
}
|
13 |
+
}
|
14 |
+
})
|
15 |
+
headers = {
|
16 |
+
'Authorization': 'Bearer secret_oG3PIzAL10np4NadmID4X93ISNJP7zHBr6CQ8Oskakb',
|
17 |
+
'Content-Type': 'application/json',
|
18 |
+
'Notion-Version': '2022-02-22'
|
19 |
+
}
|
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 |
+
print(recipe["properties"]["Name"]["title"][0]["plain_text"].strip())
|
25 |
+
print(recipe["url"])
|