-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
65 lines (52 loc) · 1.78 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Main FASTAPI app
To run the API:
source .venv/bin/activate
uvicorn main:app --reload
"""
from fastapi import FastAPI
import daily_sports_events as dse
import glass_trash_day as gtd
# from pydantic import BaseModel
# from typing import Union
## section used for the scheduled function with FAST API utils
# from fastapi_utils.session import FastAPISessionMaker
# from fastapi_utils.tasks import repeat_every
# database_uri = f"sqlite:///./test.db?check_same_thread=False"
# sessionmaker = FastAPISessionMaker(database_uri)
app = FastAPI()
# class Item(BaseModel):
# name: str
# price: float
# is_offer: Union[bool, None] = None
# date:
@app.get("/")
def read_root():
return {"message": "FASTAPIHOME"}
@app.get("/daily_sports_events")
def daily_sports_events():
"""
send daily sports events via pushbullet to the user as a notification
"""
dse.main()
return {"message": 'daily sports events sent via pushbullet'}
@app.get("/glass_trash_day")
def glass_trash_day():
"""
send pushbullet notification evening before glass trash day
"""
gtd.main()
return {"message": 'glass trash day sent via pushbullet'}
# # scheduled function from FAST API utils (no arguments allowed)
# @app.on_event("startup")
# @repeat_every(seconds=60 * 60 * 24) # in seconds (60sec * 60min * 24h = 1 day)
# def glass_trash_day_notifiction():
# """ scheduled (day by day) notification for glass trash day"""
# with sessionmaker.context_session() as db:
# pb.send_notification_by_pushbullet(db=db)
# @app.get("/items/{item_id}")
# def read_item(item_id: int, q: Union[str, None] = None):
# return {"item_id": item_id, "q": q}
# @app.put("/items/{item_id}")
# def update_item(item_id: int, item: Item):
# return {"item_name": item.name, "item_id": item_id}