-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (27 loc) · 929 Bytes
/
main.py
1
2
3
4
5
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
33
34
35
36
37
38
39
from dotenv import load_dotenv
from os import environ
import uvicorn
import schedule
import time
import threading
from notion import updateDataFromNotion as import1
from events import updateDataFromNotion as import2
if __name__ == "__main__":
print("Launching Notion -> API service.")
load_dotenv()
if "NOTION_API_TOKEN" not in environ:
raise Exception("Please provide a Notion integration token.")
def start_uvicorn():
print("Launching uvicorn.")
uvicorn.run("api:app", host="0.0.0.0", port=5000)
def refresh_from_notion():
import1()
import2()
schedule.every(5).minutes.do(import1)
schedule.every(5).minutes.do(import2)
while True:
schedule.run_pending()
time.sleep(1)
x = threading.Thread(target=refresh_from_notion, daemon=True)
x.start()
start_uvicorn()